New testcase distilled from:
[oota-llvm.git] / test / Transforms / InstCombine / shift.ll
index 6a496d3723b8654a79fc439a1f9d3eb392af13ae..016d00fc8bfc987ee5ff5f3df9e801d732bf68ee 100644 (file)
@@ -1,7 +1,7 @@
 ; This test makes sure that these instructions are properly eliminated.
 ;
 
-; RUN: as < %s | opt -instcombine | dis | not grep sh
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sh
 
 implementation
 
@@ -36,8 +36,9 @@ uint %test5a(uint %A) {
 }
 
 uint %test6(uint %A) {
-       %B = shl uint %A, ubyte 1   ;; convert to an add instruction
-       ret uint %B
+       %B = shl uint %A, ubyte 1   ;; convert to an mul instruction
+       %C = mul uint %B, 3
+       ret uint %C
 }
 
 int %test7(ubyte %A) {
@@ -64,7 +65,8 @@ ubyte %test10(ubyte %A) {              ;; (A >> 7) << 7 === A & 128
 }
 
 ubyte %test11(ubyte %A) {              ;; (A >> 3) << 4 === (A & 0x1F) << 1
-       %B = shr ubyte %A, ubyte 3
+       %a = mul ubyte %A, 3
+       %B = shr ubyte %a, ubyte 3
        %C = shl ubyte %B, ubyte 4
        ret ubyte %C
 }
@@ -76,7 +78,21 @@ int %test12(int %A) {
 }
 
 sbyte %test13(sbyte %A) {           ;; (A >> 3) << 4 === (A & -8) * 2
-       %B = shr sbyte %A, ubyte 3
+       %a = mul sbyte %A, 3
+       %B = shr sbyte %a, ubyte 3
        %C = shl sbyte %B, ubyte 4
        ret sbyte %C
 }
+
+uint %test14(uint %A) {
+       %B = shr uint %A, ubyte 4
+       %C = or uint %B, 1234
+       %D = shl uint %C, ubyte 4   ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
+       ret uint %D
+}
+uint %test14a(uint %A) {
+       %B = shl uint %A, ubyte 4
+       %C = and uint %B, 1234
+       %D = shr uint %C, ubyte 4   ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
+       ret uint %D
+}