Require a GC strategy be specified for functions which use gc.statepoint
[oota-llvm.git] / test / Transforms / InstCombine / shift.ll
index 117a9060b4a586c3993b0c8ff88a5cb79d484009..0b5b5deb68c571b2922d04bfab98c639bd77a661 100644 (file)
@@ -3,14 +3,14 @@
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
 define i32 @test1(i32 %A) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
 ; CHECK: ret i32 %A
         %B = shl i32 %A, 0              ; <i32> [#uses=1]
         ret i32 %B
 }
 
 define i32 @test2(i8 %A) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
 ; CHECK: ret i32 0
         %shift.upgrd.1 = zext i8 %A to i32              ; <i32> [#uses=1]
         %B = shl i32 0, %shift.upgrd.1          ; <i32> [#uses=1]
@@ -18,14 +18,14 @@ define i32 @test2(i8 %A) {
 }
 
 define i32 @test3(i32 %A) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
 ; CHECK: ret i32 %A
         %B = ashr i32 %A, 0             ; <i32> [#uses=1]
         ret i32 %B
 }
 
 define i32 @test4(i8 %A) {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
 ; CHECK: ret i32 0
         %shift.upgrd.2 = zext i8 %A to i32              ; <i32> [#uses=1]
         %B = ashr i32 0, %shift.upgrd.2         ; <i32> [#uses=1]
@@ -34,35 +34,70 @@ define i32 @test4(i8 %A) {
 
 
 define i32 @test5(i32 %A) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
 ; CHECK: ret i32 undef
-        %B = lshr i32 %A, 32  ;; shift all bits out 
+        %B = lshr i32 %A, 32  ;; shift all bits out
         ret i32 %B
 }
 
+define <4 x i32> @test5_splat_vector(<4 x i32> %A) {
+; CHECK-LABEL: @test5_splat_vector(
+; CHECK: ret <4 x i32> undef
+  %B = lshr <4 x i32> %A, <i32 32, i32 32, i32 32, i32 32>     ;; shift all bits out
+  ret <4 x i32> %B
+}
+
+define <4 x i32> @test5_zero_vector(<4 x i32> %A) {
+; CHECK-LABEL: @test5_zero_vector(
+; CHECK-NEXT: ret <4 x i32> %A
+  %B = lshr <4 x i32> %A, zeroinitializer
+  ret <4 x i32> %B
+}
+
+define <4 x i32> @test5_non_splat_vector(<4 x i32> %A) {
+; CHECK-LABEL: @test5_non_splat_vector(
+; CHECK-NOT: ret <4 x i32> undef
+  %B = lshr <4 x i32> %A, <i32 32, i32 1, i32 2, i32 3>
+  ret <4 x i32> %B
+}
+
 define i32 @test5a(i32 %A) {
-; CHECK: @test5a
+; CHECK-LABEL: @test5a(
 ; CHECK: ret i32 undef
-        %B = shl i32 %A, 32     ;; shift all bits out 
+        %B = shl i32 %A, 32     ;; shift all bits out
         ret i32 %B
 }
 
+define <4 x i32> @test5a_splat_vector(<4 x i32> %A) {
+; CHECK-LABEL: @test5a_splat_vector(
+; CHECK: ret <4 x i32> undef
+  %B = shl <4 x i32> %A, <i32 32, i32 32, i32 32, i32 32>     ;; shift all bits out
+  ret <4 x i32> %B
+}
+
+define <4 x i32> @test5a_non_splat_vector(<4 x i32> %A) {
+; CHECK-LABEL: @test5a_non_splat_vector(
+; CHECK-NOT: ret <4 x i32> undef
+  %B = shl <4 x i32> %A, <i32 32, i32 1, i32 2, i32 3>
+  ret <4 x i32> %B
+}
+
 define i32 @test5b() {
-; CHECK: @test5b
-; CHECK: ret i32 -1
+; CHECK-LABEL: @test5b(
+; CHECK: ret i32 0
         %B = ashr i32 undef, 2  ;; top two bits must be equal, so not undef
         ret i32 %B
 }
 
 define i32 @test5b2(i32 %A) {
-; CHECK: @test5b2
-; CHECK: ret i32 -1
+; CHECK-LABEL: @test5b2(
+; CHECK: ret i32 0
         %B = ashr i32 undef, %A  ;; top %A bits must be equal, so not undef
         ret i32 %B
 }
 
 define i32 @test6(i32 %A) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
 ; CHECK-NEXT: mul i32 %A, 6
 ; CHECK-NEXT: ret i32
         %B = shl i32 %A, 1      ;; convert to an mul instruction
@@ -71,7 +106,7 @@ define i32 @test6(i32 %A) {
 }
 
 define i32 @test6a(i32 %A) {
-; CHECK: @test6a
+; CHECK-LABEL: @test6a(
 ; CHECK-NEXT: mul i32 %A, 6
 ; CHECK-NEXT: ret i32
         %B = mul i32 %A, 3
@@ -80,16 +115,16 @@ define i32 @test6a(i32 %A) {
 }
 
 define i32 @test7(i8 %A) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
 ; CHECK-NEXT: ret i32 -1
-        %shift.upgrd.3 = zext i8 %A to i32 
+        %shift.upgrd.3 = zext i8 %A to i32
         %B = ashr i32 -1, %shift.upgrd.3  ;; Always equal to -1
         ret i32 %B
 }
 
 ;; (A << 5) << 3 === A << 8 == 0
 define i8 @test8(i8 %A) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
 ; CHECK: ret i8 0
         %B = shl i8 %A, 5               ; <i8> [#uses=1]
         %C = shl i8 %B, 3               ; <i8> [#uses=1]
@@ -98,7 +133,7 @@ define i8 @test8(i8 %A) {
 
 ;; (A << 7) >> 7 === A & 1
 define i8 @test9(i8 %A) {
-; CHECK: @test9
+; CHECK-LABEL: @test9(
 ; CHECK-NEXT: and i8 %A, 1
 ; CHECK-NEXT: ret i8
         %B = shl i8 %A, 7               ; <i8> [#uses=1]
@@ -110,7 +145,7 @@ define i8 @test9(i8 %A) {
 ;; (A >> 7) << 7 === A & 128
 ;; The shl may be valuable to scalar evolution.
 define i8 @test10(i8 %A) {
-; CHECK: @test10
+; CHECK-LABEL: @test10(
 ; CHECK-NEXT: and i8 %A, -128
 ; CHECK-NEXT: ret i8
         %B = lshr i8 %A, 7              ; <i8> [#uses=1]
@@ -120,7 +155,7 @@ define i8 @test10(i8 %A) {
 
 ;; Allow the simplification when the lshr shift is exact.
 define i8 @test10a(i8 %A) {
-; CHECK: @test10a
+; CHECK-LABEL: @test10a(
 ; CHECK-NEXT: ret i8 %A
         %B = lshr exact i8 %A, 7
         %C = shl i8 %B, 7
@@ -131,7 +166,7 @@ define i8 @test10a(i8 %A) {
 ;; (A >> 3) << 4 === (A & 0x1F) << 1
 ;; The shl may be valuable to scalar evolution.
 define i8 @test11(i8 %A) {
-; CHECK: @test11
+; CHECK-LABEL: @test11(
 ; CHECK: shl i8
 ; CHECK-NEXT: ret i8
         %a = mul i8 %A, 3               ; <i8> [#uses=1]
@@ -142,7 +177,7 @@ define i8 @test11(i8 %A) {
 
 ;; Allow the simplification in InstCombine when the lshr shift is exact.
 define i8 @test11a(i8 %A) {
-; CHECK: @test11a
+; CHECK-LABEL: @test11a(
 ; CHECK-NEXT: mul i8 %A, 6
 ; CHECK-NEXT: ret i8
         %a = mul i8 %A, 3
@@ -154,7 +189,7 @@ define i8 @test11a(i8 %A) {
 ;; This is deferred to DAGCombine unless %B is single-use.
 ;; (A >> 8) << 8 === A & -256
 define i32 @test12(i32 %A) {
-; CHECK: @test12
+; CHECK-LABEL: @test12(
 ; CHECK-NEXT: and i32 %A, -256
 ; CHECK-NEXT: ret i32
         %B = ashr i32 %A, 8             ; <i32> [#uses=1]
@@ -166,7 +201,7 @@ define i32 @test12(i32 %A) {
 ;; (A >> 3) << 4 === (A & -8) * 2
 ;; The shl may be valuable to scalar evolution.
 define i8 @test13(i8 %A) {
-; CHECK: @test13
+; CHECK-LABEL: @test13(
 ; CHECK: shl i8
 ; CHECK-NEXT: ret i8
         %a = mul i8 %A, 3               ; <i8> [#uses=1]
@@ -176,7 +211,7 @@ define i8 @test13(i8 %A) {
 }
 
 define i8 @test13a(i8 %A) {
-; CHECK: @test13a
+; CHECK-LABEL: @test13a(
 ; CHECK-NEXT: mul i8 %A, 6
 ; CHECK-NEXT: ret i8
         %a = mul i8 %A, 3
@@ -187,7 +222,7 @@ define i8 @test13a(i8 %A) {
 
 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
 define i32 @test14(i32 %A) {
-; CHECK: @test14
+; CHECK-LABEL: @test14(
 ; CHECK-NEXT: %B = and i32 %A, -19760
 ; CHECK-NEXT: or i32 %B, 19744
 ; CHECK-NEXT: ret i32
@@ -199,7 +234,7 @@ define i32 @test14(i32 %A) {
 
 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
 define i32 @test14a(i32 %A) {
-; CHECK: @test14a
+; CHECK-LABEL: @test14a(
 ; CHECK-NEXT: and i32 %A, 77
 ; CHECK-NEXT: ret i32
         %B = shl i32 %A, 4              ; <i32> [#uses=1]
@@ -209,7 +244,7 @@ define i32 @test14a(i32 %A) {
 }
 
 define i32 @test15(i1 %C) {
-; CHECK: @test15
+; CHECK-LABEL: @test15(
 ; CHECK-NEXT: select i1 %C, i32 12, i32 4
 ; CHECK-NEXT: ret i32
         %A = select i1 %C, i32 3, i32 1         ; <i32> [#uses=1]
@@ -218,7 +253,7 @@ define i32 @test15(i1 %C) {
 }
 
 define i32 @test15a(i1 %C) {
-; CHECK: @test15a
+; CHECK-LABEL: @test15a(
 ; CHECK-NEXT: select i1 %C, i32 512, i32 128
 ; CHECK-NEXT: ret i32
         %A = select i1 %C, i8 3, i8 1           ; <i8> [#uses=1]
@@ -228,18 +263,18 @@ define i32 @test15a(i1 %C) {
 }
 
 define i1 @test16(i32 %X) {
-; CHECK: @test16
+; CHECK-LABEL: @test16(
 ; CHECK-NEXT: and i32 %X, 16
 ; CHECK-NEXT: icmp ne i32
 ; CHECK-NEXT: ret i1
-        %tmp.3 = ashr i32 %X, 4 
+        %tmp.3 = ashr i32 %X, 4
         %tmp.6 = and i32 %tmp.3, 1
         %tmp.7 = icmp ne i32 %tmp.6, 0
         ret i1 %tmp.7
 }
 
 define i1 @test17(i32 %A) {
-; CHECK: @test17
+; CHECK-LABEL: @test17(
 ; CHECK-NEXT: and i32 %A, -8
 ; CHECK-NEXT: icmp eq i32
 ; CHECK-NEXT: ret i1
@@ -250,7 +285,7 @@ define i1 @test17(i32 %A) {
 
 
 define i1 @test18(i8 %A) {
-; CHECK: @test18
+; CHECK-LABEL: @test18(
 ; CHECK: ret i1 false
 
         %B = lshr i8 %A, 7              ; <i8> [#uses=1]
@@ -260,7 +295,7 @@ define i1 @test18(i8 %A) {
 }
 
 define i1 @test19(i32 %A) {
-; CHECK: @test19
+; CHECK-LABEL: @test19(
 ; CHECK-NEXT: icmp ult i32 %A, 4
 ; CHECK-NEXT: ret i1
         %B = ashr i32 %A, 2             ; <i32> [#uses=1]
@@ -271,18 +306,17 @@ define i1 @test19(i32 %A) {
 
 
 define i1 @test19a(i32 %A) {
-; CHECK: @test19a
-; CHECK-NEXT: and i32 %A, -4
-; CHECK-NEXT: icmp eq i32
+; CHECK-LABEL: @test19a(
+; CHECK-NEXT: icmp ugt i32 %A, -5
 ; CHECK-NEXT: ret i1
         %B = ashr i32 %A, 2             ; <i32> [#uses=1]
-        ;; (X & -4) == -4
+        ;; X >u ~4
         %C = icmp eq i32 %B, -1         ; <i1> [#uses=1]
         ret i1 %C
 }
 
 define i1 @test20(i8 %A) {
-; CHECK: @test20
+; CHECK-LABEL: @test20(
 ; CHECK: ret i1 false
         %B = ashr i8 %A, 7              ; <i8> [#uses=1]
         ;; false
@@ -291,7 +325,7 @@ define i1 @test20(i8 %A) {
 }
 
 define i1 @test21(i8 %A) {
-; CHECK: @test21
+; CHECK-LABEL: @test21(
 ; CHECK-NEXT: and i8 %A, 15
 ; CHECK-NEXT: icmp eq i8
 ; CHECK-NEXT: ret i1
@@ -301,7 +335,7 @@ define i1 @test21(i8 %A) {
 }
 
 define i1 @test22(i8 %A) {
-; CHECK: @test22
+; CHECK-LABEL: @test22(
 ; CHECK-NEXT: and i8 %A, 15
 ; CHECK-NEXT: icmp eq i8
 ; CHECK-NEXT: ret i1
@@ -311,7 +345,7 @@ define i1 @test22(i8 %A) {
 }
 
 define i8 @test23(i32 %A) {
-; CHECK: @test23
+; CHECK-LABEL: @test23(
 ; CHECK-NEXT: trunc i32 %A to i8
 ; CHECK-NEXT: ret i8
 
@@ -323,7 +357,7 @@ define i8 @test23(i32 %A) {
 }
 
 define i8 @test24(i8 %X) {
-; CHECK: @test24
+; CHECK-LABEL: @test24(
 ; CHECK-NEXT: and i8 %X, 3
 ; CHECK-NEXT: ret i8
         %Y = and i8 %X, -5              ; <i8> [#uses=1]
@@ -333,7 +367,7 @@ define i8 @test24(i8 %X) {
 }
 
 define i32 @test25(i32 %tmp.2, i32 %AA) {
-; CHECK: @test25
+; CHECK-LABEL: @test25(
 ; CHECK-NEXT: and i32 %tmp.2, -131072
 ; CHECK-NEXT: add i32 %{{[^,]*}}, %AA
 ; CHECK-NEXT: and i32 %{{[^,]*}}, -131072
@@ -345,9 +379,23 @@ define i32 @test25(i32 %tmp.2, i32 %AA) {
         ret i32 %tmp.6
 }
 
+define <2 x i32> @test25_vector(<2 x i32> %tmp.2, <2 x i32> %AA) {
+; CHECK-LABEL: @test25_vector(
+; CHECK: %tmp.3 = lshr <2 x i32> %tmp.2, <i32 17, i32 17>
+; CHECK-NEXT: shl <2 x i32> %tmp.3, <i32 17, i32 17>
+; CHECK-NEXT: add <2 x i32> %tmp.51, %AA
+; CHECK-NEXT: and <2 x i32> %x2, <i32 -131072, i32 -131072>
+; CHECK-NEXT: ret <2 x i32>
+  %x = lshr <2 x i32> %AA, <i32 17, i32 17>
+  %tmp.3 = lshr <2 x i32> %tmp.2, <i32 17, i32 17>
+  %tmp.5 = add <2 x i32> %tmp.3, %x
+  %tmp.6 = shl <2 x i32> %tmp.5, <i32 17, i32 17>
+  ret <2 x i32> %tmp.6
+}
+
 ;; handle casts between shifts.
 define i32 @test26(i32 %A) {
-; CHECK: @test26
+; CHECK-LABEL: @test26(
 ; CHECK-NEXT: and i32 %A, -2
 ; CHECK-NEXT: ret i32
         %B = lshr i32 %A, 1             ; <i32> [#uses=1]
@@ -358,7 +406,7 @@ define i32 @test26(i32 %A) {
 
 
 define i1 @test27(i32 %x) nounwind {
-; CHECK: @test27
+; CHECK-LABEL: @test27(
 ; CHECK-NEXT: and i32 %x, 8
 ; CHECK-NEXT: icmp ne i32
 ; CHECK-NEXT: ret i1
@@ -366,12 +414,12 @@ define i1 @test27(i32 %x) nounwind {
   %z = trunc i32 %y to i1
   ret i1 %z
 }
+
 define i8 @test28(i8 %x) {
 entry:
-; CHECK: @test28
+; CHECK-LABEL: @test28(
 ; CHECK:     icmp slt i8 %x, 0
-; CHECK-NEXT:     br i1 
+; CHECK-NEXT:     br i1
        %tmp1 = lshr i8 %x, 7
        %cond1 = icmp ne i8 %tmp1, 0
        br i1 %cond1, label %bb1, label %bb2
@@ -386,7 +434,7 @@ bb2:
 define i8 @test28a(i8 %x, i8 %y) {
 entry:
 ; This shouldn't be transformed.
-; CHECK: @test28a
+; CHECK-LABEL: @test28a(
 ; CHECK:     %tmp1 = lshr i8 %x, 7
 ; CHECK:     %cond1 = icmp eq i8 %tmp1, 0
 ; CHECK:     br i1 %cond1, label %bb2, label %bb1
@@ -407,7 +455,7 @@ entry:
        %tmp917 = trunc i64 %tmp916 to i32
        %tmp10 = lshr i32 %tmp917, 31
        ret i32 %tmp10
-; CHECK: @test29
+; CHECK-LABEL: @test29(
 ; CHECK:  %tmp916 = lshr i64 %d18, 63
 ; CHECK:  %tmp10 = trunc i64 %tmp916 to i32
 }
@@ -418,7 +466,7 @@ define i32 @test30(i32 %A, i32 %B, i32 %C) {
        %Y = shl i32 %B, %C
        %Z = and i32 %X, %Y
        ret i32 %Z
-; CHECK: @test30
+; CHECK-LABEL: @test30(
 ; CHECK: %X1 = and i32 %A, %B
 ; CHECK: %Z = shl i32 %X1, %C
 }
@@ -428,7 +476,7 @@ define i32 @test31(i32 %A, i32 %B, i32 %C) {
        %Y = lshr i32 %B, %C
        %Z = or i32 %X, %Y
        ret i32 %Z
-; CHECK: @test31
+; CHECK-LABEL: @test31(
 ; CHECK: %X1 = or i32 %A, %B
 ; CHECK: %Z = lshr i32 %X1, %C
 }
@@ -438,7 +486,7 @@ define i32 @test32(i32 %A, i32 %B, i32 %C) {
        %Y = ashr i32 %B, %C
        %Z = xor i32 %X, %Y
        ret i32 %Z
-; CHECK: @test32
+; CHECK-LABEL: @test32(
 ; CHECK: %X1 = xor i32 %A, %B
 ; CHECK: %Z = ashr i32 %X1, %C
 ; CHECK: ret i32 %Z
@@ -448,7 +496,7 @@ define i1 @test33(i32 %X) {
         %tmp1 = shl i32 %X, 7
         %tmp2 = icmp slt i32 %tmp1, 0
         ret i1 %tmp2
-; CHECK: @test33
+; CHECK-LABEL: @test33(
 ; CHECK: %tmp1.mask = and i32 %X, 16777216
 ; CHECK: %tmp2 = icmp ne i32 %tmp1.mask, 0
 }
@@ -457,7 +505,7 @@ define i1 @test34(i32 %X) {
         %tmp1 = lshr i32 %X, 7
         %tmp2 = icmp slt i32 %tmp1, 0
         ret i1 %tmp2
-; CHECK: @test34
+; CHECK-LABEL: @test34(
 ; CHECK: ret i1 false
 }
 
@@ -465,7 +513,7 @@ define i1 @test35(i32 %X) {
         %tmp1 = ashr i32 %X, 7
         %tmp2 = icmp slt i32 %tmp1, 0
         ret i1 %tmp2
-; CHECK: @test35
+; CHECK-LABEL: @test35(
 ; CHECK: %tmp2 = icmp slt i32 %X, 0
 ; CHECK: ret i1 %tmp2
 }
@@ -477,8 +525,8 @@ entry:
   %ins = or i128 %tmp23, %tmp27
   %tmp45 = lshr i128 %ins, 64
   ret i128 %tmp45
-  
-; CHECK: @test36
+
+; CHECK-LABEL: @test36(
 ; CHECK:  %tmp231 = or i128 %B, %A
 ; CHECK:  %ins = and i128 %tmp231, 18446744073709551615
 ; CHECK:  ret i128 %ins
@@ -493,8 +541,8 @@ entry:
   %tmp45 = lshr i128 %ins, 64
   %tmp46 = trunc i128 %tmp45 to i64
   ret i64 %tmp46
-  
-; CHECK: @test37
+
+; CHECK-LABEL: @test37(
 ; CHECK:  %tmp23 = shl nuw nsw i128 %tmp22, 32
 ; CHECK:  %ins = or i128 %tmp23, %A
 ; CHECK:  %tmp46 = trunc i128 %ins to i64
@@ -504,14 +552,14 @@ define i32 @test38(i32 %x) nounwind readnone {
   %rem = srem i32 %x, 32
   %shl = shl i32 1, %rem
   ret i32 %shl
-; CHECK: @test38
+; CHECK-LABEL: @test38(
 ; CHECK-NEXT: and i32 %x, 31
 ; CHECK-NEXT: shl i32 1
 ; CHECK-NEXT: ret i32
 }
 
 ; <rdar://problem/8756731>
-; CHECK: @test39
+; CHECK-LABEL: @test39(
 define i8 @test39(i32 %a0) {
 entry:
   %tmp4 = trunc i32 %a0 to i8
@@ -537,7 +585,7 @@ define i32 @test40(i32 %a, i32 %b) nounwind {
   %shl2 = shl i32 %shl1, 2
   %div = udiv i32 %a, %shl2
   ret i32 %div
-; CHECK: @test40
+; CHECK-LABEL: @test40(
 ; CHECK-NEXT: add i32 %b, 2
 ; CHECK-NEXT: lshr i32 %a
 ; CHECK-NEXT: ret i32
@@ -547,7 +595,7 @@ define i32 @test41(i32 %a, i32 %b) nounwind {
   %1 = shl i32 1, %b
   %2 = shl i32 %1, 3
   ret i32 %2
-; CHECK: @test41
+; CHECK-LABEL: @test41(
 ; CHECK-NEXT: shl i32 8, %b
 ; CHECK-NEXT: ret i32
 }
@@ -556,7 +604,7 @@ define i32 @test42(i32 %a, i32 %b) nounwind {
   %div = lshr i32 4096, %b    ; must be exact otherwise we'd divide by zero
   %div2 = udiv i32 %a, %div
   ret i32 %div2
-; CHECK: @test42
+; CHECK-LABEL: @test42(
 ; CHECK-NEXT: lshr exact i32 4096, %b
 }
 
@@ -564,7 +612,7 @@ define i32 @test43(i32 %a, i32 %b) nounwind {
   %div = shl i32 4096, %b    ; must be exact otherwise we'd divide by zero
   %div2 = udiv i32 %a, %div
   ret i32 %div2
-; CHECK: @test43
+; CHECK-LABEL: @test43(
 ; CHECK-NEXT: add i32 %b, 12
 ; CHECK-NEXT: lshr
 ; CHECK-NEXT: ret
@@ -574,7 +622,7 @@ define i32 @test44(i32 %a) nounwind {
   %y = shl nuw i32 %a, 1
   %z = shl i32 %y, 4
   ret i32 %z
-; CHECK: @test44
+; CHECK-LABEL: @test44(
 ; CHECK-NEXT: %y = shl i32 %a, 5
 ; CHECK-NEXT: ret i32 %y
 }
@@ -583,7 +631,7 @@ define i32 @test45(i32 %a) nounwind {
   %y = lshr exact i32 %a, 1
   %z = lshr i32 %y, 4
   ret i32 %z
-; CHECK: @test45
+; CHECK-LABEL: @test45(
 ; CHECK-NEXT: %y = lshr i32 %a, 5
 ; CHECK-NEXT: ret i32 %y
 }
@@ -592,7 +640,7 @@ define i32 @test46(i32 %a) {
   %y = ashr exact i32 %a, 3
   %z = shl i32 %y, 1
   ret i32 %z
-; CHECK: @test46
+; CHECK-LABEL: @test46(
 ; CHECK-NEXT: %z = ashr exact i32 %a, 2
 ; CHECK-NEXT: ret i32 %z
 }
@@ -601,7 +649,7 @@ define i32 @test47(i32 %a) {
   %y = lshr exact i32 %a, 3
   %z = shl i32 %y, 1
   ret i32 %z
-; CHECK: @test47
+; CHECK-LABEL: @test47(
 ; CHECK-NEXT: %z = lshr exact i32 %a, 2
 ; CHECK-NEXT: ret i32 %z
 }
@@ -610,7 +658,7 @@ define i32 @test48(i32 %x) {
   %A = lshr exact i32 %x, 1
   %B = shl i32 %A, 3
   ret i32 %B
-; CHECK: @test48
+; CHECK-LABEL: @test48(
 ; CHECK-NEXT: %B = shl i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -619,7 +667,7 @@ define i32 @test49(i32 %x) {
   %A = ashr exact i32 %x, 1
   %B = shl i32 %A, 3
   ret i32 %B
-; CHECK: @test49
+; CHECK-LABEL: @test49(
 ; CHECK-NEXT: %B = shl i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -628,7 +676,7 @@ define i32 @test50(i32 %x) {
   %A = shl nsw i32 %x, 1
   %B = ashr i32 %A, 3
   ret i32 %B
-; CHECK: @test50
+; CHECK-LABEL: @test50(
 ; CHECK-NEXT: %B = ashr i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -637,7 +685,7 @@ define i32 @test51(i32 %x) {
   %A = shl nuw i32 %x, 1
   %B = lshr i32 %A, 3
   ret i32 %B
-; CHECK: @test51
+; CHECK-LABEL: @test51(
 ; CHECK-NEXT: %B = lshr i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -646,7 +694,7 @@ define i32 @test52(i32 %x) {
   %A = shl nsw i32 %x, 3
   %B = ashr i32 %A, 1
   ret i32 %B
-; CHECK: @test52
+; CHECK-LABEL: @test52(
 ; CHECK-NEXT: %B = shl nsw i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -655,7 +703,7 @@ define i32 @test53(i32 %x) {
   %A = shl nuw i32 %x, 3
   %B = lshr i32 %A, 1
   ret i32 %B
-; CHECK: @test53
+; CHECK-LABEL: @test53(
 ; CHECK-NEXT: %B = shl nuw i32 %x, 2
 ; CHECK-NEXT: ret i32 %B
 }
@@ -665,7 +713,7 @@ define i32 @test54(i32 %x) {
   %shl = shl i32 %shr2, 4
   %and = and i32 %shl, 16
   ret i32 %and
-; CHECK: @test54
+; CHECK-LABEL: @test54(
 ; CHECK: shl i32 %x, 3
 }
 
@@ -675,7 +723,7 @@ define i32 @test55(i32 %x) {
   %shl = shl i32 %shr2, 4
   %or = or i32 %shl, 8
   ret i32 %or
-; CHECK: @test55
+; CHECK-LABEL: @test55(
 ; CHECK: shl i32 %x, 3
 }
 
@@ -684,84 +732,111 @@ define i32 @test56(i32 %x) {
   %shl = shl i32 %shr2, 4
   %or = or i32 %shl, 7
   ret i32 %or
-; CHECK: @test56
+; CHECK-LABEL: @test56(
 ; CHECK: shl i32 %shr2, 4
 }
 
 
 define i32 @test57(i32 %x) {
-  %shr = lshr i32 %x, 1
-  %shl = shl i32 %shr, 4
-  %and = and i32 %shl, 16
-  ret i32 %and
-; CHECK: @test57
-; CHECK: shl i32 %x, 3
-}
-
-define i32 @test58(i32 %x) {
-  %shr = lshr i32 %x, 1
-  %shl = shl i32 %shr, 4
-  %or = or i32 %shl, 8
-  ret i32 %or
-; CHECK: @test58
-; CHECK: shl i32 %x, 3
-}
-
-define i32 @test59(i32 %x) {
   %shr = ashr i32 %x, 1
   %shl = shl i32 %shr, 4
   %or = or i32 %shl, 7
   ret i32 %or
-; CHECK: @test59
+; CHECK-LABEL: @test57(
 ; CHECK: %shl = shl i32 %shr1, 4
 }
 
 
-define i32 @test60(i32 %x) {
+define i32 @test58(i32 %x) {
   %shr = ashr i32 %x, 4
   %shl = shl i32 %shr, 1
   %or = or i32 %shl, 1
   ret i32 %or
-; CHECK: @test60
+; CHECK-LABEL: @test58(
 ; CHECK: ashr i32 %x, 3
 }
 
 
-define i32 @test61(i32 %x) {
+define i32 @test59(i32 %x) {
   %shr = ashr i32 %x, 4
   %shl = shl i32 %shr, 1
   %or = or i32 %shl, 2
   ret i32 %or
-; CHECK: @test61
+; CHECK-LABEL: @test59(
 ; CHECK: ashr i32 %x, 4
 }
 
 ; propagate "exact" trait
-define i32 @test62(i32 %x) {
+define i32 @test60(i32 %x) {
   %shr = ashr exact i32 %x, 4
   %shl = shl i32 %shr, 1
   %or = or i32 %shl, 1
   ret i32 %or
-; CHECK: @test62
+; CHECK-LABEL: @test60(
 ; CHECK: ashr exact i32 %x, 3
 }
 
-; CHECK: @test63
-; CHECK: shl <4 x i32> <i32 1, i32 2, i32 4, i32 8>, %B
-define <4 x i32> @test63(i32 %n) {
-entry:
-  %K = insertelement <4 x i32> undef, i32 %n, i32 0
-  %B = shufflevector <4 x i32> %K, <4 x i32> undef, <4 x i32> zeroinitializer
-  %A = add <4 x i32> %B, <i32 0, i32 1, i32 2, i32 3>
-  %T = shl <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %A
-  ret <4 x i32> %T
+; PR17026
+; CHECK-LABEL: @test61(
+; CHECK-NOT: sh
+; CHECK: ret
+define void @test61(i128 %arg) {
+bb:
+  br i1 undef, label %bb1, label %bb12
+
+bb1:                                              ; preds = %bb11, %bb
+  br label %bb2
+
+bb2:                                              ; preds = %bb7, %bb1
+  br i1 undef, label %bb3, label %bb7
+
+bb3:                                              ; preds = %bb2
+  %tmp = lshr i128 %arg, 36893488147419103232
+  %tmp4 = shl i128 %tmp, 0
+  %tmp5 = or i128 %tmp4, undef
+  %tmp6 = trunc i128 %tmp5 to i16
+  br label %bb8
+
+bb7:                                              ; preds = %bb2
+  br i1 undef, label %bb8, label %bb2
+
+bb8:                                              ; preds = %bb7, %bb3
+  %tmp9 = phi i16 [ %tmp6, %bb3 ], [ undef, %bb7 ]
+  %tmp10 = icmp eq i16 %tmp9, 0
+  br i1 %tmp10, label %bb11, label %bb12
+
+bb11:                                             ; preds = %bb8
+  br i1 undef, label %bb1, label %bb12
+
+bb12:                                             ; preds = %bb11, %bb8, %bb
+  ret void
 }
 
-; CHECK: @test64
-; CHECK: shl i32 524288, %n
-define i32 @test64(i32 %n) {
-entry:
-  %A = add i32 %n, 19
-  %T = shl i32 1 , %A
-  ret i32 %T
+define i32 @test62(i32 %a) {
+; CHECK-LABEL: @test62(
+; CHECK-NEXT: ret i32 undef
+  %b = ashr i32 %a, 32  ; shift all bits out
+  ret i32 %b
+}
+
+define <4 x i32> @test62_splat_vector(<4 x i32> %a) {
+; CHECK-LABEL: @test62_splat_vector
+; CHECK-NEXT: ret <4 x i32> undef
+  %b = ashr <4 x i32> %a, <i32 32, i32 32, i32 32, i32 32>  ; shift all bits out
+  ret <4 x i32> %b
+}
+
+define <4 x i32> @test62_non_splat_vector(<4 x i32> %a) {
+; CHECK-LABEL: @test62_non_splat_vector
+; CHECK-NOT: ret <4 x i32> undef
+  %b = ashr <4 x i32> %a, <i32 32, i32 0, i32 1, i32 2>  ; shift all bits out
+  ret <4 x i32> %b
+}
+
+define <2 x i65> @test_63(<2 x i64> %t) {
+; CHECK-LABEL: @test_63
+  %a = zext <2 x i64> %t to <2 x i65>
+  %sext = shl <2 x i65> %a, <i65 33, i65 33>
+  %b = ashr <2 x i65> %sext, <i65 33, i65 33>
+  ret <2 x i65> %b
 }