diff --git a/llvm/test/Transforms/JumpThreading/phi-known.ll b/llvm/test/Transforms/JumpThreading/phi-known.ll --- a/llvm/test/Transforms/JumpThreading/phi-known.ll +++ b/llvm/test/Transforms/JumpThreading/phi-known.ll @@ -1,16 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 ; RUN: opt -S -passes=jump-threading %s | FileCheck %s ; Value of predicate known on all inputs (trivial case) ; Note: InstCombine/EarlyCSE would also get this case define void @test(ptr %p, ptr %addr) { -; CHECK-LABEL: @test +; CHECK-LABEL: define void @test +; CHECK-SAME: (ptr [[P:%.*]], ptr [[ADDR:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP0:%.*]] = icmp eq ptr [[P]], null +; CHECK-NEXT: br i1 [[CMP0]], label [[EXIT:%.*]], label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[P1:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ [[P1]], [[LOOP]] ] +; CHECK-NEXT: br label [[LOOP]] +; CHECK: exit: +; CHECK-NEXT: ret void +; entry: %cmp0 = icmp eq ptr %p, null br i1 %cmp0, label %exit, label %loop loop: -; CHECK-LABEL: loop: -; CHECK-NEXT: phi -; CHECK-NEXT: br label %loop %p1 = phi ptr [%p, %entry], [%p1, %loop] %cmp1 = icmp eq ptr %p1, null br i1 %cmp1, label %exit, label %loop @@ -20,7 +28,19 @@ ; Value of predicate known on all inputs (non-trivial) define void @test2(ptr %p) { -; CHECK-LABEL: @test2 +; CHECK-LABEL: define void @test2 +; CHECK-SAME: (ptr [[P:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP0:%.*]] = icmp eq ptr [[P]], null +; CHECK-NEXT: br i1 [[CMP0]], label [[EXIT:%.*]], label [[BACKEDGE:%.*]] +; CHECK: backedge: +; CHECK-NEXT: [[P1:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ [[P2:%.*]], [[BACKEDGE]] ] +; CHECK-NEXT: [[P2]] = load ptr, ptr [[P1]], align 8 +; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[P2]], null +; CHECK-NEXT: br i1 [[CMP2]], label [[EXIT]], label [[BACKEDGE]] +; CHECK: exit: +; CHECK-NEXT: ret void +; entry: %cmp0 = icmp eq ptr %p, null br i1 %cmp0, label %exit, label %loop @@ -29,12 +49,6 @@ %cmp1 = icmp eq ptr %p1, null br i1 %cmp1, label %exit, label %backedge backedge: -; CHECK-LABEL: backedge: -; CHECK-NEXT: phi -; CHECK-NEXT: load -; CHECK-NEXT: cmp -; CHECK-NEXT: br -; CHECK-DAG: label %backedge %p2 = load ptr, ptr %p1 %cmp2 = icmp eq ptr %p2, null br i1 %cmp2, label %exit, label %loop @@ -46,15 +60,22 @@ ; Well, we could unroll this loop exactly twice, but that's ; a different transform. define void @test_mixed(ptr %p) { -; CHECK-LABEL: @test_mixed +; CHECK-LABEL: define void @test_mixed +; CHECK-SAME: (ptr [[P:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP0:%.*]] = icmp eq ptr [[P]], null +; CHECK-NEXT: br i1 [[CMP0]], label [[EXIT:%.*]], label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[P1:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ [[P1]], [[LOOP]] ] +; CHECK-NEXT: [[CMP1:%.*]] = icmp ne ptr [[P1]], null +; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT]], label [[LOOP]] +; CHECK: exit: +; CHECK-NEXT: ret void +; entry: %cmp0 = icmp eq ptr %p, null br i1 %cmp0, label %exit, label %loop loop: -; CHECK-LABEL: loop: -; CHECK-NEXT: phi -; CHECK-NEXT: %cmp1 = icmp -; CHECK-NEXT: br i1 %cmp1 %p1 = phi ptr [%p, %entry], [%p1, %loop] %cmp1 = icmp ne ptr %p1, null br i1 %cmp1, label %exit, label %loop @@ -69,18 +90,31 @@ declare void @hoo() define void @test3(i32 %m, ptr %t1) { +; CHECK-LABEL: define void @test3 +; CHECK-SAME: (i32 [[M:%.*]], ptr [[T1:%.*]]) { +; CHECK-NEXT: L1: +; CHECK-NEXT: [[T0:%.*]] = add i32 [[M]], 7 +; CHECK-NEXT: [[T2:%.*]] = load ptr, ptr [[T1]], align 8 +; CHECK-NEXT: [[T3:%.*]] = icmp eq ptr [[T2]], null +; CHECK-NEXT: br i1 [[T3]], label [[L4:%.*]], label [[L3:%.*]] +; CHECK: L3: +; CHECK-NEXT: [[T4:%.*]] = load i32, ptr [[T2]], align 4 +; CHECK-NEXT: [[T6:%.*]] = icmp eq i32 [[T0]], [[T4]] +; CHECK-NEXT: br i1 [[T6]], label [[L4]], label [[L5:%.*]] +; CHECK: L4: +; CHECK-NEXT: call void @goo() +; CHECK-NEXT: ret void +; CHECK: L5: +; CHECK-NEXT: call void @hoo() +; CHECK-NEXT: ret void +; L1: %t0 = add i32 %m, 7 %t2 = load ptr, ptr %t1, align 8 -; CHECK-LABEL: @test3 -; CHECK: %t3 = icmp eq ptr %t2, null -; CHECK: br i1 %t3, label %[[LABEL2:.*]], label %[[LABEL1:.*]] %t3 = icmp eq ptr %t2, null br i1 %t3, label %L3, label %L2 -; CHECK: [[LABEL1]]: -; CHECK-NEXT: %t4 = load i32, ptr %t2, align 4 L2: %t4 = load i32, ptr %t2, align 4 br label %L3 @@ -90,8 +124,6 @@ %t6 = icmp eq i32 %t0, %t5 br i1 %t6, label %L4, label %L5 -; CHECK: [[LABEL2]]: -; CHECK-NEXT: call void @goo() L4: call void @goo() ret void