[llvm] 534e913 - [InstCombine] auto-generate test checks; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 19 08:07:16 PDT 2020


Author: Sanjay Patel
Date: 2020-09-19T11:06:47-04:00
New Revision: 534e9132afceed8af8b4c309dab1547cc750e9fe

URL: https://github.com/llvm/llvm-project/commit/534e9132afceed8af8b4c309dab1547cc750e9fe
DIFF: https://github.com/llvm/llvm-project/commit/534e9132afceed8af8b4c309dab1547cc750e9fe.diff

LOG: [InstCombine] auto-generate test checks; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/phi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/phi.ll b/llvm/test/Transforms/InstCombine/phi.ll
index 7c3f3102e0bc..9ac0bd2c7e3d 100644
--- a/llvm/test/Transforms/InstCombine/phi.ll
+++ b/llvm/test/Transforms/InstCombine/phi.ll
@@ -1,149 +1,198 @@
-; This test makes sure that these instructions are properly eliminated.
-;
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128:n8:16:32:64"
 
 define i32 @test1(i32 %A, i1 %b) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       BB1:
+; CHECK-NEXT:    ret i32 [[A:%.*]]
+; CHECK:       BB2:
+; CHECK-NEXT:    ret i32 [[A]]
+;
 BB0:
-        br i1 %b, label %BB1, label %BB2
+  br i1 %b, label %BB1, label %BB2
 
 BB1:
-        ; Combine away one argument PHI nodes
-        %B = phi i32 [ %A, %BB0 ]               
-        ret i32 %B
+  ; Combine away one argument PHI nodes
+  %B = phi i32 [ %A, %BB0 ]
+  ret i32 %B
 
 BB2:
-        ret i32 %A
-; CHECK-LABEL: @test1(
-; CHECK: BB1:
-; CHECK-NEXT: ret i32 %A
+  ret i32 %A
 }
 
 define i32 @test2(i32 %A, i1 %b) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       BB1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       BB2:
+; CHECK-NEXT:    ret i32 [[A:%.*]]
+;
 BB0:
-        br i1 %b, label %BB1, label %BB2
+  br i1 %b, label %BB1, label %BB2
 
 BB1:
-        br label %BB2
+  br label %BB2
 
 BB2:
-        ; Combine away PHI nodes with same values
-        %B = phi i32 [ %A, %BB0 ], [ %A, %BB1 ]         
-        ret i32 %B
-; CHECK-LABEL: @test2(
-; CHECK: BB2:
-; CHECK-NEXT: ret i32 %A
+  ; Combine away PHI nodes with same values
+  %B = phi i32 [ %A, %BB0 ], [ %A, %BB1 ]
+  ret i32 %B
 }
 
 define i32 @test3(i32 %A, i1 %b) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    ret i32 [[A:%.*]]
+;
 BB0:
-        br label %Loop
+  br label %Loop
 
 Loop:
-        ; PHI has same value always.
-        %B = phi i32 [ %A, %BB0 ], [ %B, %Loop ]
-        br i1 %b, label %Loop, label %Exit
+  ; PHI has same value always.
+  %B = phi i32 [ %A, %BB0 ], [ %B, %Loop ]
+  br i1 %b, label %Loop, label %Exit
 
 Exit:
-        ret i32 %B
-; CHECK-LABEL: @test3(
-; CHECK: Exit:
-; CHECK-NEXT: ret i32 %A
+  ret i32 %B
 }
 
 define i32 @test4(i1 %b) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    ret i32 7
+; CHECK:       Loop:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[L2:%.*]], label [[LOOP:%.*]]
+; CHECK:       L2:
+; CHECK-NEXT:    br label [[LOOP]]
+;
 BB0:
-        ; Loop is unreachable
-        ret i32 7
+  ; Loop is unreachable
+  ret i32 7
 
 Loop:           ; preds = %L2, %Loop
-        ; PHI has same value always.
-        %B = phi i32 [ %B, %L2 ], [ %B, %Loop ]         
-        br i1 %b, label %L2, label %Loop
+  ; PHI has same value always.
+  %B = phi i32 [ %B, %L2 ], [ %B, %Loop ]
+  br i1 %b, label %L2, label %Loop
 
 L2:             ; preds = %Loop
-        br label %Loop
-; CHECK-LABEL: @test4(
-; CHECK: Loop:
-; CHECK-NEXT: br i1 %b
+  br label %Loop
 }
 
 define i32 @test5(i32 %A, i1 %b) {
+; CHECK-LABEL: @test5(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    ret i32 [[A:%.*]]
+;
 BB0:
-        br label %Loop
+  br label %Loop
 
 Loop:           ; preds = %Loop, %BB0
-        ; PHI has same value always.
-        %B = phi i32 [ %A, %BB0 ], [ undef, %Loop ]             
-        br i1 %b, label %Loop, label %Exit
+  ; PHI has same value always.
+  %B = phi i32 [ %A, %BB0 ], [ undef, %Loop ]
+  br i1 %b, label %Loop, label %Exit
 
 Exit:           ; preds = %Loop
-        ret i32 %B
-; CHECK-LABEL: @test5(
-; CHECK: Loop:
-; CHECK-NEXT: br i1 %b
-; CHECK: Exit:
-; CHECK-NEXT: ret i32 %A
+  ret i32 %B
 }
 
 define i32 @test6(i16 %A, i1 %b) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       BB1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       BB2:
+; CHECK-NEXT:    [[B:%.*]] = zext i16 [[A:%.*]] to i32
+; CHECK-NEXT:    ret i32 [[B]]
+;
 BB0:
-        %X = zext i16 %A to i32              
-        br i1 %b, label %BB1, label %BB2
+  %X = zext i16 %A to i32
+  br i1 %b, label %BB1, label %BB2
 
-BB1:           
-        %Y = zext i16 %A to i32              
-        br label %BB2
+BB1:
+  %Y = zext i16 %A to i32
+  br label %BB2
 
-BB2:           
-        ;; Suck casts into phi
-        %B = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]         
-        ret i32 %B
-; CHECK-LABEL: @test6(
-; CHECK: BB2:
-; CHECK: zext i16 %A to i32
-; CHECK-NEXT: ret i32
+BB2:
+  ;; Suck casts into phi
+  %B = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
+  ret i32 %B
 }
 
 define i32 @test7(i32 %A, i1 %b) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    ret i32 0
+;
 BB0:
-        br label %Loop
+  br label %Loop
 
 Loop:           ; preds = %Loop, %BB0
-        ; PHI is dead.
-        %B = phi i32 [ %A, %BB0 ], [ %C, %Loop ]                
-        %C = add i32 %B, 123            
-        br i1 %b, label %Loop, label %Exit
+  ; PHI is dead.
+  %B = phi i32 [ %A, %BB0 ], [ %C, %Loop ]
+  %C = add i32 %B, 123
+  br i1 %b, label %Loop, label %Exit
 
 Exit:           ; preds = %Loop
-        ret i32 0
-; CHECK-LABEL: @test7(
-; CHECK: Loop:
-; CHECK-NEXT: br i1 %b
+  ret i32 0
 }
 
 define i32* @test8({ i32, i32 } *%A, i1 %b) {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       BB1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       BB2:
+; CHECK-NEXT:    [[B:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[A:%.*]], i64 0, i32 1
+; CHECK-NEXT:    ret i32* [[B]]
+;
 BB0:
-        %X = getelementptr inbounds { i32, i32 }, { i32, i32 } *%A, i32 0, i32 1
-        br i1 %b, label %BB1, label %BB2
+  %X = getelementptr inbounds { i32, i32 }, { i32, i32 } *%A, i32 0, i32 1
+  br i1 %b, label %BB1, label %BB2
 
 BB1:
-        %Y = getelementptr { i32, i32 }, { i32, i32 } *%A, i32 0, i32 1
-        br label %BB2
+  %Y = getelementptr { i32, i32 }, { i32, i32 } *%A, i32 0, i32 1
+  br label %BB2
 
 BB2:
-        ;; Suck GEPs into phi
-        %B = phi i32* [ %X, %BB0 ], [ %Y, %BB1 ]
-        ret i32* %B
-; CHECK-LABEL: @test8(
-; CHECK-NOT: phi
-; CHECK: BB2:
-; CHECK-NEXT: %B = getelementptr { i32, i32 }, { i32, i32 }* %A 
-; CHECK-NEXT: ret i32* %B
+  ;; Suck GEPs into phi
+  %B = phi i32* [ %X, %BB0 ], [ %Y, %BB1 ]
+  ret i32* %B
 }
 
 define i32 @test9(i32* %A, i32* %B) {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i32* [[A:%.*]], null
+; CHECK-NEXT:    br i1 [[C]], label [[BB1:%.*]], label [[BB:%.*]]
+; CHECK:       bb:
+; CHECK-NEXT:    br label [[BB2:%.*]]
+; CHECK:       bb1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       bb2:
+; CHECK-NEXT:    [[E_IN:%.*]] = phi i32* [ [[B:%.*]], [[BB]] ], [ [[A]], [[BB1]] ]
+; CHECK-NEXT:    [[E:%.*]] = load i32, i32* [[E_IN]], align 1
+; CHECK-NEXT:    ret i32 [[E]]
+;
 entry:
   %c = icmp eq i32* %A, null
   br i1 %c, label %bb1, label %bb
@@ -159,15 +208,23 @@ bb1:
 bb2:
   %E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
   ret i32 %E
-; CHECK-LABEL: @test9(
-; CHECK:       bb2:
-; CHECK-NEXT:        phi i32* [ %B, %bb ], [ %A, %bb1 ]
-; CHECK-NEXT:   %E = load i32, i32* %{{[^,]*}}, align 1
-; CHECK-NEXT:   ret i32 %E
 
 }
 
 define i32 @test10(i32* %A, i32* %B) {
+; CHECK-LABEL: @test10(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i32* [[A:%.*]], null
+; CHECK-NEXT:    br i1 [[C]], label [[BB1:%.*]], label [[BB:%.*]]
+; CHECK:       bb:
+; CHECK-NEXT:    br label [[BB2:%.*]]
+; CHECK:       bb1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       bb2:
+; CHECK-NEXT:    [[E_IN:%.*]] = phi i32* [ [[B:%.*]], [[BB]] ], [ [[A]], [[BB1]] ]
+; CHECK-NEXT:    [[E:%.*]] = load i32, i32* [[E_IN]], align 16
+; CHECK-NEXT:    ret i32 [[E]]
+;
 entry:
   %c = icmp eq i32* %A, null
   br i1 %c, label %bb1, label %bb
@@ -183,11 +240,6 @@ bb1:
 bb2:
   %E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
   ret i32 %E
-; CHECK-LABEL: @test10(
-; CHECK:       bb2:
-; CHECK-NEXT:        phi i32* [ %B, %bb ], [ %A, %bb1 ]
-; CHECK-NEXT:   %E = load i32, i32* %{{[^,]*}}, align 16
-; CHECK-NEXT:   ret i32 %E
 }
 
 
@@ -195,6 +247,20 @@ bb2:
 declare i1 @test11a()
 
 define i1 @test11() {
+; CHECK-LABEL: @test11(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = call i1 @test11a()
+; CHECK-NEXT:    br i1 [[B]], label [[ONE:%.*]], label [[TWO:%.*]]
+; CHECK:       one:
+; CHECK-NEXT:    [[C:%.*]] = call i1 @test11a()
+; CHECK-NEXT:    br i1 [[C]], label [[TWO]], label [[END:%.*]]
+; CHECK:       two:
+; CHECK-NEXT:    [[D:%.*]] = call i1 @test11a()
+; CHECK-NEXT:    br i1 [[D]], label [[ONE]], label [[END]]
+; CHECK:       end:
+; CHECK-NEXT:    [[Z:%.*]] = call i1 @test11a()
+; CHECK-NEXT:    ret i1 [[Z]]
+;
 entry:
   %a = alloca i32
   %i = ptrtoint i32* %a to i64
@@ -219,116 +285,151 @@ end:
   store i32 10, i32* %g
   %z = call i1 @test11a()
   ret i1 %z
-; CHECK-LABEL: @test11(
-; CHECK-NOT: phi i32
-; CHECK: ret i1 %z
 }
 
 
 define i64 @test12(i1 %cond, i8* %Ptr, i64 %Val) {
+; CHECK-LABEL: @test12(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[END:%.*]], label [[TWO:%.*]]
+; CHECK:       two:
+; CHECK-NEXT:    br label [[END]]
+; CHECK:       end:
+; CHECK-NEXT:    [[T869_0_OFF64:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[VAL:%.*]], [[TWO]] ]
+; CHECK-NEXT:    [[T41:%.*]] = ptrtoint i8* [[PTR:%.*]] to i64
+; CHECK-NEXT:    [[T2:%.*]] = add i64 [[T869_0_OFF64]], [[T41]]
+; CHECK-NEXT:    ret i64 [[T2]]
+;
 entry:
-  %tmp41 = ptrtoint i8* %Ptr to i64
-  %tmp42 = zext i64 %tmp41 to i128
+  %t41 = ptrtoint i8* %Ptr to i64
+  %t42 = zext i64 %t41 to i128
   br i1 %cond, label %end, label %two
 
 two:
-  %tmp36 = zext i64 %Val to i128            ; <i128> [#uses=1]
-  %tmp37 = shl i128 %tmp36, 64                    ; <i128> [#uses=1]
-  %ins39 = or i128 %tmp42, %tmp37                 ; <i128> [#uses=1]
+  %t36 = zext i64 %Val to i128            ; <i128> [#uses=1]
+  %t37 = shl i128 %t36, 64                    ; <i128> [#uses=1]
+  %ins39 = or i128 %t42, %t37                 ; <i128> [#uses=1]
   br label %end
 
 end:
-  %tmp869.0 = phi i128 [ %tmp42, %entry ], [ %ins39, %two ]
-  %tmp32 = trunc i128 %tmp869.0 to i64            ; <i64> [#uses=1]
-  %tmp29 = lshr i128 %tmp869.0, 64                ; <i128> [#uses=1]
-  %tmp30 = trunc i128 %tmp29 to i64               ; <i64> [#uses=1]
+  %t869.0 = phi i128 [ %t42, %entry ], [ %ins39, %two ]
+  %t32 = trunc i128 %t869.0 to i64            ; <i64> [#uses=1]
+  %t29 = lshr i128 %t869.0, 64                ; <i128> [#uses=1]
+  %t30 = trunc i128 %t29 to i64               ; <i64> [#uses=1]
 
-  %tmp2 = add i64 %tmp32, %tmp30
-  ret i64 %tmp2
-; CHECK-LABEL: @test12(
-; CHECK-NOT: zext
-; CHECK: end:
-; CHECK-NEXT: phi i64 [ 0, %entry ], [ %Val, %two ]
-; CHECK-NOT: phi
-; CHECK: ret i64
+  %t2 = add i64 %t32, %t30
+  ret i64 %t2
 }
 
 declare void @test13f(double, i32)
 
 define void @test13(i1 %cond, i32 %V1, double %Vald) {
+; CHECK-LABEL: @test13(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[END:%.*]], label [[TWO:%.*]]
+; CHECK:       two:
+; CHECK-NEXT:    br label [[END]]
+; CHECK:       end:
+; CHECK-NEXT:    [[TMP0:%.*]] = phi double [ 0.000000e+00, [[ENTRY:%.*]] ], [ [[VALD:%.*]], [[TWO]] ]
+; CHECK-NEXT:    call void @test13f(double [[TMP0]], i32 [[V1:%.*]])
+; CHECK-NEXT:    ret void
+;
 entry:
-  %tmp42 = zext i32 %V1 to i128
+  %t42 = zext i32 %V1 to i128
   br i1 %cond, label %end, label %two
 
 two:
   %Val = bitcast double %Vald to i64
-  %tmp36 = zext i64 %Val to i128            ; <i128> [#uses=1]
-  %tmp37 = shl i128 %tmp36, 64                    ; <i128> [#uses=1]
-  %ins39 = or i128 %tmp42, %tmp37                 ; <i128> [#uses=1]
+  %t36 = zext i64 %Val to i128            ; <i128> [#uses=1]
+  %t37 = shl i128 %t36, 64                    ; <i128> [#uses=1]
+  %ins39 = or i128 %t42, %t37                 ; <i128> [#uses=1]
   br label %end
 
 end:
-  %tmp869.0 = phi i128 [ %tmp42, %entry ], [ %ins39, %two ]
-  %tmp32 = trunc i128 %tmp869.0 to i32
-  %tmp29 = lshr i128 %tmp869.0, 64                ; <i128> [#uses=1]
-  %tmp30 = trunc i128 %tmp29 to i64               ; <i64> [#uses=1]
-  %tmp31 = bitcast i64 %tmp30 to double
-  
-  call void @test13f(double %tmp31, i32 %tmp32)
+  %t869.0 = phi i128 [ %t42, %entry ], [ %ins39, %two ]
+  %t32 = trunc i128 %t869.0 to i32
+  %t29 = lshr i128 %t869.0, 64                ; <i128> [#uses=1]
+  %t30 = trunc i128 %t29 to i64               ; <i64> [#uses=1]
+  %t31 = bitcast i64 %t30 to double
+
+  call void @test13f(double %t31, i32 %t32)
   ret void
-; CHECK-LABEL: @test13(
-; CHECK-NOT: zext
-; CHECK: end:
-; CHECK-NEXT: phi double [ 0.000000e+00, %entry ], [ %Vald, %two ]
-; CHECK-NEXT: call void @test13f(double {{[^,]*}}, i32 %V1)
-; CHECK: ret void
 }
 
 define i640 @test14a(i320 %A, i320 %B, i1 %b1) {
+; CHECK-LABEL: @test14a(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    [[C_IN:%.*]] = phi i320 [ [[A:%.*]], [[BB0:%.*]] ], [ [[B:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    br i1 [[B1:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    [[C:%.*]] = zext i320 [[C_IN]] to i640
+; CHECK-NEXT:    ret i640 [[C]]
+;
 BB0:
-        %a = zext i320 %A to i640
-        %b = zext i320 %B to i640
-        br label %Loop
+  %a = zext i320 %A to i640
+  %b = zext i320 %B to i640
+  br label %Loop
 
 Loop:
-        %C = phi i640 [ %a, %BB0 ], [ %b, %Loop ]             
-        br i1 %b1, label %Loop, label %Exit
+  %C = phi i640 [ %a, %BB0 ], [ %b, %Loop ]
+  br i1 %b1, label %Loop, label %Exit
 
 Exit:           ; preds = %Loop
-        ret i640 %C
-; CHECK-LABEL: @test14a(
-; CHECK: Loop:
-; CHECK-NEXT: phi i320
+  ret i640 %C
 }
 
-define i160 @test14b(i320 %A, i320 %B, i1 %b1) {
+define i160 @test14b(i320 %pA, i320 %pB, i1 %b1) {
+; CHECK-LABEL: @test14b(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    [[A:%.*]] = trunc i320 [[PA:%.*]] to i160
+; CHECK-NEXT:    [[B:%.*]] = trunc i320 [[PB:%.*]] to i160
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    [[C:%.*]] = phi i160 [ [[A]], [[BB0:%.*]] ], [ [[B]], [[LOOP]] ]
+; CHECK-NEXT:    br i1 [[B1:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    ret i160 [[C]]
+;
 BB0:
-        %a = trunc i320 %A to i160
-        %b = trunc i320 %B to i160
-        br label %Loop
+  %a = trunc i320 %pA to i160
+  %b = trunc i320 %pB to i160
+  br label %Loop
 
 Loop:
-        %C = phi i160 [ %a, %BB0 ], [ %b, %Loop ]             
-        br i1 %b1, label %Loop, label %Exit
+  %C = phi i160 [ %a, %BB0 ], [ %b, %Loop ]
+  br i1 %b1, label %Loop, label %Exit
 
 Exit:           ; preds = %Loop
-        ret i160 %C
-; CHECK-LABEL: @test14b(
-; CHECK: Loop:
-; CHECK-NEXT: phi i160
+  ret i160 %C
 }
 
 declare i64 @test15a(i64)
 
 define i64 @test15b(i64 %A, i1 %b) {
 ; CHECK-LABEL: @test15b(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[B:%.*]], label [[ONE:%.*]], label [[TWO:%.*]]
+; CHECK:       one:
+; CHECK-NEXT:    [[X_OFF64:%.*]] = phi i64 [ [[A:%.*]], [[ENTRY:%.*]] ], [ [[Y_OFF64:%.*]], [[TWO]] ]
+; CHECK-NEXT:    [[C:%.*]] = call i64 @test15a(i64 [[X_OFF64]])
+; CHECK-NEXT:    br label [[TWO]]
+; CHECK:       two:
+; CHECK-NEXT:    [[Y_OFF0:%.*]] = phi i64 [ [[A]], [[ENTRY]] ], [ [[C]], [[ONE]] ]
+; CHECK-NEXT:    [[Y_OFF64]] = phi i64 [ [[A]], [[ENTRY]] ], [ 0, [[ONE]] ]
+; CHECK-NEXT:    [[D:%.*]] = call i64 @test15a(i64 [[Y_OFF64]])
+; CHECK-NEXT:    [[TMP0:%.*]] = and i64 [[D]], 1
+; CHECK-NEXT:    [[D1_NOT:%.*]] = icmp eq i64 [[TMP0]], 0
+; CHECK-NEXT:    br i1 [[D1_NOT]], label [[END:%.*]], label [[ONE]]
+; CHECK:       end:
+; CHECK-NEXT:    ret i64 [[Y_OFF0]]
+;
 entry:
   %i0 = zext i64 %A to i128
   %i1 = shl i128 %i0, 64
   %i = or i128 %i1, %i0
   br i1 %b, label %one, label %two
-; CHECK: entry:
-; CHECK-NEXT: br i1 %b
 
 one:
   %x = phi i128 [%i, %entry], [%y, %two]
@@ -338,9 +439,6 @@ one:
   %c1 = zext i64 %c to i128
   br label %two
 
-; CHECK: one:
-; CHECK-NEXT: phi i64
-; CHECK-NEXT: %c = call i64 @test15a
 
 two:
   %y = phi i128 [%i, %entry], [%c1, %one]
@@ -350,20 +448,39 @@ two:
   %d1 = trunc i64 %d to i1
   br i1 %d1, label %one, label %end
 
-; CHECK: two:
-; CHECK-NEXT: phi i64
-; CHECK-NEXT: phi i64
-; CHECK-NEXT: %d = call i64 @test15a
 
 end:
   %g = trunc i128 %y to i64
   ret i64 %g
-; CHECK: end: 
-; CHECK-NEXT: ret i64
 }
 
 ; PR6512 - Shouldn't merge loads from 
diff erent addr spaces.
 define i32 @test16(i32 addrspace(1)* %pointer1, i32 %flag, i32* %pointer2)
+; CHECK-LABEL: @test16(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[RETVAL:%.*]] = alloca i32, align 4
+; CHECK-NEXT:    [[POINTER1_ADDR:%.*]] = alloca i32 addrspace(1)*, align 8
+; CHECK-NEXT:    [[POINTER2_ADDR:%.*]] = alloca i32*, align 8
+; CHECK-NEXT:    store i32 addrspace(1)* [[POINTER1:%.*]], i32 addrspace(1)** [[POINTER1_ADDR]], align 8
+; CHECK-NEXT:    store i32* [[POINTER2:%.*]], i32** [[POINTER2_ADDR]], align 8
+; CHECK-NEXT:    [[TOBOOL_NOT:%.*]] = icmp eq i32 [[FLAG:%.*]], 0
+; CHECK-NEXT:    br i1 [[TOBOOL_NOT]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       return:
+; CHECK-NEXT:    [[T7:%.*]] = load i32, i32* [[RETVAL]], align 4
+; CHECK-NEXT:    ret i32 [[T7]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[STOREMERGE:%.*]] = phi i32 [ [[T5:%.*]], [[IF_ELSE]] ], [ [[T2:%.*]], [[IF_THEN]] ]
+; CHECK-NEXT:    store i32 [[STOREMERGE]], i32* [[RETVAL]], align 4
+; CHECK-NEXT:    br label [[RETURN:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    [[T1:%.*]] = load i32 addrspace(1)*, i32 addrspace(1)** [[POINTER1_ADDR]], align 8
+; CHECK-NEXT:    [[T2]] = load i32, i32 addrspace(1)* [[T1]], align 4
+; CHECK-NEXT:    br label [[IF_END:%.*]]
+; CHECK:       if.else:
+; CHECK-NEXT:    [[T3:%.*]] = load i32*, i32** [[POINTER2_ADDR]], align 8
+; CHECK-NEXT:    [[T5]] = load i32, i32* [[T3]], align 4
+; CHECK-NEXT:    br label [[IF_END]]
+;
 nounwind {
 entry:
   %retval = alloca i32, align 4                   ; <i32*> [#uses=2]
@@ -375,56 +492,71 @@ entry:
   store i32 %flag, i32* %flag.addr
   store i32* %pointer2, i32** %pointer2.addr
   store i32 10, i32* %res
-  %tmp = load i32, i32* %flag.addr                     ; <i32> [#uses=1]
-  %tobool = icmp ne i32 %tmp, 0                   ; <i1> [#uses=1]
+  %t = load i32, i32* %flag.addr                     ; <i32> [#uses=1]
+  %tobool = icmp ne i32 %t, 0                   ; <i1> [#uses=1]
   br i1 %tobool, label %if.then, label %if.else
 
 return:                                           ; preds = %if.end
-  %tmp7 = load i32, i32* %retval                       ; <i32> [#uses=1]
-  ret i32 %tmp7
+  %t7 = load i32, i32* %retval                       ; <i32> [#uses=1]
+  ret i32 %t7
 
 if.end:                                           ; preds = %if.else, %if.then
-  %tmp6 = load i32, i32* %res                          ; <i32> [#uses=1]
-  store i32 %tmp6, i32* %retval
+  %t6 = load i32, i32* %res                          ; <i32> [#uses=1]
+  store i32 %t6, i32* %retval
   br label %return
 
 if.then:                                          ; preds = %entry
-  %tmp1 = load i32 addrspace(1)*, i32 addrspace(1)** %pointer1.addr  ; <i32 addrspace(1)*>
-  %arrayidx = getelementptr i32, i32 addrspace(1)* %tmp1, i32 0 ; <i32 addrspace(1)*> [#uses=1]
-  %tmp2 = load i32, i32 addrspace(1)* %arrayidx        ; <i32> [#uses=1]
-  store i32 %tmp2, i32* %res
+  %t1 = load i32 addrspace(1)*, i32 addrspace(1)** %pointer1.addr  ; <i32 addrspace(1)*>
+  %arrayidx = getelementptr i32, i32 addrspace(1)* %t1, i32 0 ; <i32 addrspace(1)*> [#uses=1]
+  %t2 = load i32, i32 addrspace(1)* %arrayidx        ; <i32> [#uses=1]
+  store i32 %t2, i32* %res
   br label %if.end
 
 if.else:                                          ; preds = %entry
-  %tmp3 = load i32*, i32** %pointer2.addr               ; <i32*> [#uses=1]
-  %arrayidx4 = getelementptr i32, i32* %tmp3, i32 0    ; <i32*> [#uses=1]
-  %tmp5 = load i32, i32* %arrayidx4                    ; <i32> [#uses=1]
-  store i32 %tmp5, i32* %res
+  %t3 = load i32*, i32** %pointer2.addr               ; <i32*> [#uses=1]
+  %arrayidx4 = getelementptr i32, i32* %t3, i32 0    ; <i32*> [#uses=1]
+  %t5 = load i32, i32* %arrayidx4                    ; <i32> [#uses=1]
+  store i32 %t5, i32* %res
   br label %if.end
 }
 
 ; PR4413
 declare i32 @ext()
-; CHECK-LABEL: @test17(
 define i32 @test17(i1 %a) {
+; CHECK-LABEL: @test17(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[A:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       bb1:
+; CHECK-NEXT:    [[TMP0:%.*]] = tail call i32 @ext()
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       bb2:
+; CHECK-NEXT:    [[RES:%.*]] = phi i32 [ [[TMP0]], [[BB1]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    ret i32 [[RES]]
+;
 entry:
-    br i1 %a, label %bb1, label %bb2
+  br i1 %a, label %bb1, label %bb2
 
 bb1:        ; preds = %entry
-    %0 = tail call i32 @ext()        ; <i32> [#uses=1]
-    br label %bb2
+  %0 = tail call i32 @ext()        ; <i32> [#uses=1]
+  br label %bb2
 
 bb2:        ; preds = %bb1, %entry
-    %cond = phi i1 [ true, %bb1 ], [ false, %entry ]        ; <i1> [#uses=1]
-; CHECK-NOT: phi i1
-; CHECK:     %res = phi i32 [ %0, %bb1 ], [ 0, %entry ]
-; CHECK:     ret i32 %res
-    %val = phi i32 [ %0, %bb1 ], [ 0, %entry ]        ; <i32> [#uses=1]
-    %res = select i1 %cond, i32 %val, i32 0        ; <i32> [#uses=1]
-    ret i32 %res
+  %cond = phi i1 [ true, %bb1 ], [ false, %entry ]        ; <i1> [#uses=1]
+  %val = phi i32 [ %0, %bb1 ], [ 0, %entry ]        ; <i32> [#uses=1]
+  %res = select i1 %cond, i32 %val, i32 0        ; <i32> [#uses=1]
+  ret i32 %res
 }
 
 define i1 @test18(i1 %cond) {
+; CHECK-LABEL: @test18(
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK:       true:
+; CHECK-NEXT:    br label [[RET:%.*]]
+; CHECK:       false:
+; CHECK-NEXT:    br label [[RET]]
+; CHECK:       ret:
+; CHECK-NEXT:    ret i1 false
+;
   %zero = alloca i32
   %one = alloca i32
   br i1 %cond, label %true, label %false
@@ -436,11 +568,18 @@ ret:
   %ptr = phi i32* [ %zero, %true ] , [ %one, %false ]
   %isnull = icmp eq i32* %ptr, null
   ret i1 %isnull
-; CHECK-LABEL: @test18(
-; CHECK: ret i1 false
 }
 
 define i1 @test19(i1 %cond, double %x) {
+; CHECK-LABEL: @test19(
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK:       true:
+; CHECK-NEXT:    br label [[RET:%.*]]
+; CHECK:       false:
+; CHECK-NEXT:    br label [[RET]]
+; CHECK:       ret:
+; CHECK-NEXT:    ret i1 true
+;
   br i1 %cond, label %true, label %false
 true:
   br label %ret
@@ -450,11 +589,18 @@ ret:
   %p = phi double [ %x, %true ], [ 0x7FF0000000000000, %false ]; RHS = +infty
   %cmp = fcmp ule double %x, %p
   ret i1 %cmp
-; CHECK-LABEL: @test19(
-; CHECK: ret i1 true
 }
 
 define i1 @test20(i1 %cond) {
+; CHECK-LABEL: @test20(
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK:       true:
+; CHECK-NEXT:    br label [[RET:%.*]]
+; CHECK:       false:
+; CHECK-NEXT:    br label [[RET]]
+; CHECK:       ret:
+; CHECK-NEXT:    ret i1 false
+;
   %a = alloca i32
   %b = alloca i32
   %c = alloca i32
@@ -467,11 +613,20 @@ ret:
   %p = phi i32* [ %a, %true ], [ %b, %false ]
   %r = icmp eq i32* %p, %c
   ret i1 %r
-; CHECK-LABEL: @test20(
-; CHECK: ret i1 false
 }
 
 define i1 @test21(i1 %c1, i1 %c2) {
+; CHECK-LABEL: @test21(
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK:       true:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       false:
+; CHECK-NEXT:    br label [[LOOP]]
+; CHECK:       loop:
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[RET:%.*]], label [[LOOP]]
+; CHECK:       ret:
+; CHECK-NEXT:    ret i1 false
+;
   %a = alloca i32
   %b = alloca i32
   %c = alloca i32
@@ -486,12 +641,21 @@ loop:
   br i1 %c2, label %ret, label %loop
 ret:
   ret i1 %r
-; CHECK-LABEL: @test21(
-; CHECK: ret i1 false
 }
 
 define void @test22() {
 ; CHECK-LABEL: @test22(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[Y:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[Y]] = add i32 [[PHI]], 1
+; CHECK-NEXT:    [[O:%.*]] = or i32 [[Y]], [[PHI]]
+; CHECK-NEXT:    [[E:%.*]] = icmp eq i32 [[O]], [[Y]]
+; CHECK-NEXT:    br i1 [[E]], label [[LOOP]], label [[RET:%.*]]
+; CHECK:       ret:
+; CHECK-NEXT:    ret void
+;
 entry:
   br label %loop
 loop:
@@ -500,56 +664,78 @@ loop:
   %o = or i32 %y, %phi
   %e = icmp eq i32 %o, %y
   br i1 %e, label %loop, label %ret
-; CHECK: br i1 %e
 ret:
   ret void
 }
 
-define i32 @test23(i32 %A, i1 %b, i32 * %P) {
+define i32 @test23(i32 %A, i1 %pb, i32 * %P) {
+; CHECK-LABEL: @test23(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    [[PHI_BO:%.*]] = add i32 [[A:%.*]], 19
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       Loop:
+; CHECK-NEXT:    [[B:%.*]] = phi i32 [ [[PHI_BO]], [[BB0:%.*]] ], [ 61, [[LOOP]] ]
+; CHECK-NEXT:    store i32 [[B]], i32* [[P:%.*]], align 4
+; CHECK-NEXT:    br i1 [[PB:%.*]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       Exit:
+; CHECK-NEXT:    ret i32 [[B]]
+;
 BB0:
-        br label %Loop
+  br label %Loop
 
 Loop:           ; preds = %Loop, %BB0
-        ; PHI has same value always.
-        %B = phi i32 [ %A, %BB0 ], [ 42, %Loop ]
-        %D = add i32 %B, 19
-        store i32 %D, i32* %P
-        br i1 %b, label %Loop, label %Exit
+  ; PHI has same value always.
+  %B = phi i32 [ %A, %BB0 ], [ 42, %Loop ]
+  %D = add i32 %B, 19
+  store i32 %D, i32* %P
+  br i1 %pb, label %Loop, label %Exit
 
 Exit:           ; preds = %Loop
-        %E = add i32 %B, 19
-        ret i32 %E
-; CHECK-LABEL: @test23(
-; CHECK: %phi.bo = add i32 %A, 19
-; CHECK: Loop:
-; CHECK-NEXT: %B = phi i32 [ %phi.bo, %BB0 ], [ 61, %Loop ]
-; CHECK: Exit:
-; CHECK-NEXT: ret i32 %B
+  %E = add i32 %B, 19
+  ret i32 %E
 }
 
 define i32 @test24(i32 %A, i1 %cond) {
+; CHECK-LABEL: @test24(
+; CHECK-NEXT:  BB0:
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK:       BB1:
+; CHECK-NEXT:    br label [[BB2]]
+; CHECK:       BB2:
+; CHECK-NEXT:    [[C:%.*]] = add nuw i32 [[A:%.*]], 1
+; CHECK-NEXT:    ret i32 [[C]]
+;
 BB0:
-        %X = add nuw nsw i32 %A, 1
-        br i1 %cond, label %BB1, label %BB2
+  %X = add nuw nsw i32 %A, 1
+  br i1 %cond, label %BB1, label %BB2
 
 BB1:
-        %Y = add nuw i32 %A, 1
-        br label %BB2
+  %Y = add nuw i32 %A, 1
+  br label %BB2
 
 BB2:
-        %C = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
-        ret i32 %C
-; CHECK-LABEL: @test24(
-; CHECK-NOT: phi
-; CHECK: BB2:
-; CHECK-NEXT: %C = add nuw i32 %A, 1
-; CHECK-NEXT: ret i32 %C
+  %C = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
+  ret i32 %C
 }
 
 ; Same as test11, but used to be missed due to a bug.
 declare i1 @test25a()
 
 define i1 @test25() {
+; CHECK-LABEL: @test25(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = call i1 @test25a()
+; CHECK-NEXT:    br i1 [[B]], label [[ONE:%.*]], label [[TWO:%.*]]
+; CHECK:       one:
+; CHECK-NEXT:    [[C:%.*]] = call i1 @test25a()
+; CHECK-NEXT:    br i1 [[C]], label [[TWO]], label [[END:%.*]]
+; CHECK:       two:
+; CHECK-NEXT:    [[D:%.*]] = call i1 @test25a()
+; CHECK-NEXT:    br i1 [[D]], label [[ONE]], label [[END]]
+; CHECK:       end:
+; CHECK-NEXT:    [[Z:%.*]] = call i1 @test25a()
+; CHECK-NEXT:    ret i1 [[Z]]
+;
 entry:
   %a = alloca i32
   %i = ptrtoint i32* %a to i64
@@ -574,14 +760,34 @@ end:
   store i32 10, i32* %g
   %z = call i1 @test25a()
   ret i1 %z
-; CHECK-LABEL: @test25(
-; CHECK-NOT: phi i32
-; CHECK: ret i1 %z
 }
 
 declare i1 @test26a()
 
 define i1 @test26(i32 %n) {
+; CHECK-LABEL: @test26(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = call i1 @test26a()
+; CHECK-NEXT:    br label [[ONE:%.*]]
+; CHECK:       one:
+; CHECK-NEXT:    [[C:%.*]] = call i1 @test26a()
+; CHECK-NEXT:    switch i32 [[N:%.*]], label [[END:%.*]] [
+; CHECK-NEXT:    i32 2, label [[TWO:%.*]]
+; CHECK-NEXT:    i32 3, label [[THREE:%.*]]
+; CHECK-NEXT:    ]
+; CHECK:       two:
+; CHECK-NEXT:    [[D:%.*]] = call i1 @test26a()
+; CHECK-NEXT:    switch i32 [[N]], label [[END]] [
+; CHECK-NEXT:    i32 10, label [[ONE]]
+; CHECK-NEXT:    i32 30, label [[THREE]]
+; CHECK-NEXT:    ]
+; CHECK:       three:
+; CHECK-NEXT:    [[E:%.*]] = call i1 @test26a()
+; CHECK-NEXT:    br i1 [[E]], label [[ONE]], label [[TWO]]
+; CHECK:       end:
+; CHECK-NEXT:    [[Z:%.*]] = call i1 @test26a()
+; CHECK-NEXT:    ret i1 [[Z]]
+;
 entry:
   %a = alloca i32
   %i = ptrtoint i32* %a to i64
@@ -592,16 +798,16 @@ one:
   %x = phi i64 [%y, %two], [%w, %three], [%i, %entry]
   %c = call i1 @test26a()
   switch i32 %n, label %end [
-          i32 2, label %two
-          i32 3, label %three
+  i32 2, label %two
+  i32 3, label %three
   ]
 
 two:
   %y = phi i64 [%x, %one], [%w, %three]
   %d = call i1 @test26a()
   switch i32 %n, label %end [
-          i32 10, label %one
-          i32 30, label %three
+  i32 10, label %one
+  i32 30, label %three
   ]
 
 three:
@@ -617,14 +823,15 @@ end:
   store i32 10, i32* %g
   %z = call i1 @test26a()
   ret i1 %z
-; CHECK-LABEL: @test26(
-; CHECK-NOT: phi i32
-; CHECK: ret i1 %z
 }
 
-; CHECK-LABEL: @test27(
-; CHECK: ret i32 undef
 define i32 @test27(i1 %b) {
+; CHECK-LABEL: @test27(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[DONE:%.*]]
+; CHECK:       done:
+; CHECK-NEXT:    ret i32 undef
+;
 entry:
   br label %done
 done:
@@ -637,11 +844,28 @@ done:
 ; because we can shrink that constant to the smaller phi type.
 
 define i1 @PR24766(i8 %x1, i8 %x2, i8 %condition) {
+; CHECK-LABEL: @PR24766(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[CONDITION:%.*]] to i32
+; CHECK-NEXT:    switch i32 [[CONV]], label [[EPILOG:%.*]] [
+; CHECK-NEXT:    i32 0, label [[SW1:%.*]]
+; CHECK-NEXT:    i32 1, label [[SW2:%.*]]
+; CHECK-NEXT:    ]
+; CHECK:       sw1:
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[X1:%.*]], [[X2:%.*]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       sw2:
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp sle i8 [[X1]], [[X2]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       epilog:
+; CHECK-NEXT:    [[CONDITIONMET_SHRUNK:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP2]], [[SW2]] ], [ [[CMP1]], [[SW1]] ]
+; CHECK-NEXT:    ret i1 [[CONDITIONMET_SHRUNK]]
+;
 entry:
   %conv = sext i8 %condition to i32
   switch i32 %conv, label %epilog [
-    i32 0, label %sw1
-    i32 1, label %sw2
+  i32 0, label %sw1
+  i32 1, label %sw2
   ]
 
 sw1:
@@ -659,20 +883,34 @@ epilog:
   %tobool = icmp ne i8 %conditionMet, 0
   ret i1 %tobool
 
-; CHECK-LABEL: @PR24766(
-; CHECK: %[[RES:.*]] = phi i1 [ false, %entry ], [ %cmp2, %sw2 ], [ %cmp1, %sw1 ]
-; CHECK-NEXT: ret i1 %[[RES]] 
 }
 
 ; Same as above (a phi with more than 2 operands), but no constants
- 
+
 define i1 @PR24766_no_constants(i8 %x1, i8 %x2, i8 %condition, i1 %another_condition) {
+; CHECK-LABEL: @PR24766_no_constants(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[CONDITION:%.*]] to i32
+; CHECK-NEXT:    switch i32 [[CONV]], label [[EPILOG:%.*]] [
+; CHECK-NEXT:    i32 0, label [[SW1:%.*]]
+; CHECK-NEXT:    i32 1, label [[SW2:%.*]]
+; CHECK-NEXT:    ]
+; CHECK:       sw1:
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[X1:%.*]], [[X2:%.*]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       sw2:
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp sle i8 [[X1]], [[X2]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       epilog:
+; CHECK-NEXT:    [[CONDITIONMET_IN:%.*]] = phi i1 [ [[ANOTHER_CONDITION:%.*]], [[ENTRY:%.*]] ], [ [[CMP2]], [[SW2]] ], [ [[CMP1]], [[SW1]] ]
+; CHECK-NEXT:    ret i1 [[CONDITIONMET_IN]]
+;
 entry:
   %frombool0 = zext i1 %another_condition to i8
   %conv = sext i8 %condition to i32
   switch i32 %conv, label %epilog [
-    i32 0, label %sw1
-    i32 1, label %sw2
+  i32 0, label %sw1
+  i32 1, label %sw2
   ]
 
 sw1:
@@ -690,19 +928,32 @@ epilog:
   %tobool = icmp ne i8 %conditionMet, 0
   ret i1 %tobool
 
-; CHECK-LABEL: @PR24766_no_constants(
-; CHECK: %[[RES:.*]] = phi i1 [ %another_condition, %entry ], [ %cmp2, %sw2 ], [ %cmp1, %sw1 ]
-; CHECK-NEXT: ret i1 %[[RES]]
 }
 
 ; Same as above (a phi with more than 2 operands), but two constants
 
 define i1 @PR24766_two_constants(i8 %x1, i8 %x2, i8 %condition) {
+; CHECK-LABEL: @PR24766_two_constants(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[CONDITION:%.*]] to i32
+; CHECK-NEXT:    switch i32 [[CONV]], label [[EPILOG:%.*]] [
+; CHECK-NEXT:    i32 0, label [[SW1:%.*]]
+; CHECK-NEXT:    i32 1, label [[SW2:%.*]]
+; CHECK-NEXT:    ]
+; CHECK:       sw1:
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[X1:%.*]], [[X2:%.*]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       sw2:
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       epilog:
+; CHECK-NEXT:    [[CONDITIONMET:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ true, [[SW2]] ], [ [[CMP1]], [[SW1]] ]
+; CHECK-NEXT:    ret i1 [[CONDITIONMET]]
+;
 entry:
   %conv = sext i8 %condition to i32
   switch i32 %conv, label %epilog [
-    i32 0, label %sw1
-    i32 1, label %sw2
+  i32 0, label %sw1
+  i32 1, label %sw2
   ]
 
 sw1:
@@ -720,20 +971,37 @@ epilog:
   %tobool = icmp ne i8 %conditionMet, 0
   ret i1 %tobool
 
-; CHECK-LABEL: @PR24766_two_constants(
-; CHECK: %[[RES:.*]] = phi i1 [ false, %entry ], [ true, %sw2 ], [ %cmp1, %sw1 ]
-; CHECK-NEXT: ret i1 %[[RES]]
 }
 
 ; Same as above (a phi with more than 2 operands), but two constants and two variables
 
 define i1 @PR24766_two_constants_two_var(i8 %x1, i8 %x2, i8 %condition) {
+; CHECK-LABEL: @PR24766_two_constants_two_var(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[CONDITION:%.*]] to i32
+; CHECK-NEXT:    switch i32 [[CONV]], label [[EPILOG:%.*]] [
+; CHECK-NEXT:    i32 0, label [[SW1:%.*]]
+; CHECK-NEXT:    i32 1, label [[SW2:%.*]]
+; CHECK-NEXT:    i32 2, label [[SW3:%.*]]
+; CHECK-NEXT:    ]
+; CHECK:       sw1:
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[X1:%.*]], [[X2:%.*]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       sw2:
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp sle i8 [[X1]], [[X2]]
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       sw3:
+; CHECK-NEXT:    br label [[EPILOG]]
+; CHECK:       epilog:
+; CHECK-NEXT:    [[CONDITIONMET_SHRUNK:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP2]], [[SW2]] ], [ [[CMP1]], [[SW1]] ], [ true, [[SW3]] ]
+; CHECK-NEXT:    ret i1 [[CONDITIONMET_SHRUNK]]
+;
 entry:
   %conv = sext i8 %condition to i32
   switch i32 %conv, label %epilog [
-    i32 0, label %sw1
-    i32 1, label %sw2
-    i32 2, label %sw3
+  i32 0, label %sw1
+  i32 1, label %sw2
+  i32 2, label %sw3
   ]
 
 sw1:
@@ -756,15 +1024,20 @@ epilog:
   %tobool = icmp ne i8 %conditionMet, 0
   ret i1 %tobool
 
-; CHECK-LABEL: @PR24766_two_constants_two_var(
-; CHECK: %[[RES:.*]] = phi i1 [ false, %entry ], [ %cmp2, %sw2 ], [ %cmp1, %sw1 ], [ true, %sw3 ]
-; CHECK-NEXT: ret i1 %[[RES]]
 }
 
-; CHECK-LABEL: phi_allnonzeroconstant
-; CHECK-NOT: phi i32
-; CHECK: ret i1 false
 define i1 @phi_allnonzeroconstant(i1 %c, i32 %a, i32 %b) {
+; CHECK-LABEL: @phi_allnonzeroconstant(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br label [[IF_END:%.*]]
+; CHECK:       if.else:
+; CHECK-NEXT:    call void @dummy()
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    ret i1 false
+;
 entry:
   br i1 %c, label %if.then, label %if.else
 
@@ -785,12 +1058,18 @@ if.end:                                           ; preds = %if.else, %if.then
 
 declare void @dummy()
 
-; CHECK-LABEL: @phi_knownnonzero_eq
-; CHECK-LABEL: if.then:
-; CHECK-NOT: select
-; CHECK-LABEL: if.end:
-; CHECK: phi i32 [ 1, %if.then ]
 define i1 @phi_knownnonzero_eq(i32 %n, i32 %s, i32* nocapture readonly %P) {
+; CHECK-LABEL: @phi_knownnonzero_eq(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp slt i32 [[N:%.*]], [[S:%.*]]
+; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[A_0:%.*]] = phi i32 [ 1, [[IF_THEN]] ], [ [[N]], [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i32 [[A_0]], 0
+; CHECK-NEXT:    ret i1 [[CMP1]]
+;
 entry:
   %tobool = icmp slt  i32 %n, %s
   br i1 %tobool, label %if.end, label %if.then
@@ -807,12 +1086,18 @@ if.end:                                           ; preds = %entry, %if.then
   ret i1  %cmp1
 }
 
-; CHECK-LABEL: @phi_knownnonzero_ne
-; CHECK-LABEL: if.then:
-; CHECK-NOT: select
-; CHECK-LABEL: if.end:
-; CHECK: phi i32 [ 1, %if.then ]
 define i1 @phi_knownnonzero_ne(i32 %n, i32 %s, i32* nocapture readonly %P) {
+; CHECK-LABEL: @phi_knownnonzero_ne(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp slt i32 [[N:%.*]], [[S:%.*]]
+; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[A_0:%.*]] = phi i32 [ 1, [[IF_THEN]] ], [ [[N]], [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp ne i32 [[A_0]], 0
+; CHECK-NEXT:    ret i1 [[CMP1]]
+;
 entry:
   %tobool = icmp slt  i32 %n, %s
   br i1 %tobool, label %if.end, label %if.then
@@ -829,12 +1114,20 @@ if.end:                                           ; preds = %entry, %if.then
   ret i1  %cmp1
 }
 
-; CHECK-LABEL: @phi_knownnonzero_eq_2
-; CHECK-LABEL: if.then:
-; CHECK-NOT: select
-; CHECK-LABEL: if.end:
-; CHECK: phi i32 [ 2, %if.else ]
 define i1 @phi_knownnonzero_eq_2(i32 %n, i32 %s, i32* nocapture readonly %P) {
+; CHECK-LABEL: @phi_knownnonzero_eq_2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp slt i32 [[N:%.*]], [[S:%.*]]
+; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br i1 true, label [[IF_ELSE:%.*]], label [[IF_END]]
+; CHECK:       if.else:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[A_0:%.*]] = phi i32 [ 2, [[IF_ELSE]] ], [ [[N]], [[ENTRY:%.*]] ], [ 2, [[IF_THEN]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i32 [[A_0]], 0
+; CHECK-NEXT:    ret i1 [[CMP1]]
+;
 entry:
   %tobool = icmp slt  i32 %n, %s
   br i1 %tobool, label %if.then, label %if.end
@@ -855,12 +1148,20 @@ if.end:                                           ; preds = %entry, %if.then
   ret i1  %cmp1
 }
 
-; CHECK-LABEL: @phi_knownnonzero_ne_2
-; CHECK-LABEL: if.then:
-; CHECK-NOT: select
-; CHECK-LABEL: if.end:
-; CHECK: phi i32 [ 2, %if.else ]
 define i1 @phi_knownnonzero_ne_2(i32 %n, i32 %s, i32* nocapture readonly %P) {
+; CHECK-LABEL: @phi_knownnonzero_ne_2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp slt i32 [[N:%.*]], [[S:%.*]]
+; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br i1 true, label [[IF_ELSE:%.*]], label [[IF_END]]
+; CHECK:       if.else:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[A_0:%.*]] = phi i32 [ 2, [[IF_ELSE]] ], [ [[N]], [[ENTRY:%.*]] ], [ 2, [[IF_THEN]] ]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp ne i32 [[A_0]], 0
+; CHECK-NEXT:    ret i1 [[CMP1]]
+;
 entry:
   %tobool = icmp slt  i32 %n, %s
   br i1 %tobool, label %if.then, label %if.end


        


More information about the llvm-commits mailing list