Add some tests for difficult reassociation cases
authorChris Lattner <sabre@nondot.org>
Wed, 13 Aug 2003 19:01:09 +0000 (19:01 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 13 Aug 2003 19:01:09 +0000 (19:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7824 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/add.ll

index d9788b99cac008137260ee321def2cb0239cec76..a70d49065abb0f71c60168a2b674b3384e402426 100644 (file)
@@ -1,9 +1,6 @@
 ; This test makes sure that add instructions are properly eliminated.
-;
-; This also tests that a subtract with a constant is properly converted
-; to a add w/negative constant
 
-; RUN: as < %s | opt -instcombine -die | dis | not grep add
+; RUN: as < %s | opt -instcombine -die | dis | grep -v OK | not grep add
 
 implementation
 
@@ -72,3 +69,27 @@ bool %test11(ubyte %A) {
         %c = setne ubyte %B, 0    ; === A != 1
         ret bool %c
 }
+
+int %test12(int %A, int %B) {
+       %C_OK = add int %B, %A       ; Should be transformed into shl A, 1
+       br label %X
+X:
+       %D = add int %C_OK, %A 
+       ret int %D
+}
+
+int %test13(int %A, int %B, int %C) {
+       %D_OK = add int %A, %B
+       %E_OK = add int %D_OK, %C
+       %F = add int %E_OK, %A        ;; shl A, 1
+       ret int %F
+}
+
+uint %test14(uint %offset, uint %difference) {
+        %tmp.2 = and uint %difference, 3
+        %tmp.3_OK = add uint %tmp.2, %offset
+        %tmp.5.mask = and uint %difference, 4294967292
+        %tmp.8 = add uint %tmp.3_OK, %tmp.5.mask ; == add %offset, %difference
+        ret uint %tmp.8
+}
+