From 50286abebe0a86f2ac7bf6d6cc6439522108be9b Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 18 Nov 2024 16:03:00 -0700 Subject: [PATCH 1/6] Remove br i1 undef in JumpThreading directory --- .../JumpThreading/PR33357-lvi-recursion.ll | 2 +- llvm/test/Transforms/JumpThreading/basic.ll | 3 +- llvm/test/Transforms/JumpThreading/crash.ll | 22 ++++++------- .../Transforms/JumpThreading/ddt-crash.ll | 10 +++--- .../Transforms/JumpThreading/ddt-crash4.ll | 32 ++++++++++++++----- .../Transforms/JumpThreading/landing-pad.ll | 24 +++++++++----- llvm/test/Transforms/JumpThreading/pr22086.ll | 13 +++++--- llvm/test/Transforms/JumpThreading/pr9331.ll | 7 ++-- .../JumpThreading/preserving-debugloc-br.ll | 5 ++- .../JumpThreading/unreachable-loops.ll | 20 ++++++------ 10 files changed, 82 insertions(+), 56 deletions(-) diff --git a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll b/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll index 76ee63b37734c..a36f81bda55ab 100644 --- a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll +++ b/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll @@ -12,7 +12,7 @@ define void @f(i32 %p1) { bb0: %0 = icmp eq i32 %p1, 0 - br i1 undef, label %bb6, label %bb1 + br i1 true, label %bb6, label %bb1 bb1: br label %bb2 diff --git a/llvm/test/Transforms/JumpThreading/basic.ll b/llvm/test/Transforms/JumpThreading/basic.ll index bb8eeb7137164..f37843903a5b1 100644 --- a/llvm/test/Transforms/JumpThreading/basic.ll +++ b/llvm/test/Transforms/JumpThreading/basic.ll @@ -60,12 +60,11 @@ F2: } -; Undef handling. define i32 @test3(i1 %cond) { ; CHECK-LABEL: @test3( ; CHECK-NEXT: T1: ; CHECK-NEXT: ret i32 42 - br i1 undef, label %T1, label %F1 + br i1 true, label %T1, label %F1 T1: ret i32 42 diff --git a/llvm/test/Transforms/JumpThreading/crash.ll b/llvm/test/Transforms/JumpThreading/crash.ll index 69ef3b9762908..4fab807864db8 100644 --- a/llvm/test/Transforms/JumpThreading/crash.ll +++ b/llvm/test/Transforms/JumpThreading/crash.ll @@ -239,7 +239,7 @@ return: } ; PR6119 -define i32 @test8(i32 %action) nounwind { +define i32 @test8(i32 %action, i1 %arg) nounwind { entry: switch i32 %action, label %lor.rhs [ i32 1, label %if.then @@ -257,14 +257,14 @@ lor.end: ; preds = %lor.rhs, %entry br i1 %cmp103, label %for.cond, label %if.then for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body + br i1 %arg, label %if.then, label %for.body for.body: ; preds = %for.cond br label %for.cond } ; PR6119 -define i32 @test9(i32 %action) nounwind { +define i32 @test9(i32 %action, i1 %arg) nounwind { entry: switch i32 %action, label %lor.rhs [ i32 1, label %if.then @@ -283,14 +283,14 @@ lor.end: ; preds = %lor.rhs, %entry br i1 %cmp103, label %for.cond, label %if.then for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body + br i1 %arg, label %if.then, label %for.body for.body: ; preds = %for.cond br label %for.cond } ; PR6119 -define i32 @test10(i32 %action, i32 %type) nounwind { +define i32 @test10(i32 %action, i32 %type, i1 %arg) nounwind { entry: %cmp2 = icmp eq i32 %type, 0 ; [#uses=1] switch i32 %action, label %lor.rhs [ @@ -311,7 +311,7 @@ lor.end: ; preds = %lor.rhs, %entry br i1 %cmp103, label %for.cond, label %if.then for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body + br i1 %arg, label %if.then, label %for.body for.body: ; preds = %for.cond br label %for.cond @@ -391,7 +391,7 @@ if.end: ; preds = %land.end69 } ; PR7647 -define void @test15() nounwind { +define void @test15(i1 %arg) nounwind { entry: ret void @@ -420,7 +420,7 @@ lbl_709: br label %if.end949 for.cond603: ; preds = %for.body607, %if.end336 - br i1 undef, label %for.cond603, label %if.end949 + br i1 %arg, label %for.cond603, label %if.end949 if.end949: ; preds = %for.cond603, %lbl_709, %for.cond111 %l_678.2 = phi i64 [ %l_678.5, %for.cond111 ], [ undef, %lbl_709 ], [ 5, %for.cond603 ] ; [#uses=1] @@ -430,7 +430,7 @@ for.body1016: ; preds = %for.cond1012 br label %for.body1016 for.cond1035: ; preds = %for.inc1055, %if.then1026 - br i1 undef, label %for.cond1040, label %lbl_664 + br i1 %arg, label %for.cond1040, label %lbl_664 for.cond1040: ; preds = %for.body1044, %for.cond1035 ret void @@ -461,9 +461,9 @@ if.end: ret void } -define void @test17() { +define void @test17(i1 %arg) { entry: - br i1 undef, label %bb269.us.us, label %bb269.us.us.us + br i1 %arg, label %bb269.us.us, label %bb269.us.us.us bb269.us.us.us: %indvar = phi i64 [ %indvar.next, %bb287.us.us.us ], [ 0, %entry ] diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash.ll b/llvm/test/Transforms/JumpThreading/ddt-crash.ll index 3f191a9d49dbc..b0bba1a2dd0c4 100644 --- a/llvm/test/Transforms/JumpThreading/ddt-crash.ll +++ b/llvm/test/Transforms/JumpThreading/ddt-crash.ll @@ -66,7 +66,7 @@ bb11: ret void } -define void @spam(ptr %arg) { +define void @spam(ptr %arg, i1 %arg2) { ; CHECK-LABEL: @spam( ; CHECK-NEXT: bb: ; CHECK-NEXT: [[TMP:%.*]] = load i8, ptr undef, align 8 @@ -87,9 +87,11 @@ define void @spam(ptr %arg) { ; CHECK-NEXT: i8 0, label [[BB11]] ; CHECK-NEXT: i8 1, label [[BB10:%.*]] ; CHECK-NEXT: i8 2, label [[BB10]] -; CHECK-NEXT: i8 3, label [[BB8]] -; CHECK-NEXT: i8 4, label [[BB8]] +; CHECK-NEXT: i8 3, label [[BB7:%.*]] +; CHECK-NEXT: i8 4, label [[BB7]] ; CHECK-NEXT: ] +; CHECK: bb7: +; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB8]], label [[BB10]] ; CHECK: bb8: ; CHECK-NEXT: [[TMP9:%.*]] = icmp eq ptr undef, [[ARG:%.*]] ; CHECK-NEXT: br i1 [[TMP9]], label [[BB10]], label [[BB2]] @@ -175,7 +177,7 @@ bb6: br label %bb7 bb7: - br i1 undef, label %bb8, label %bb10 + br i1 %arg2, label %bb8, label %bb10 bb8: %tmp9 = icmp eq ptr undef, %arg diff --git a/llvm/test/Transforms/JumpThreading/ddt-crash4.ll b/llvm/test/Transforms/JumpThreading/ddt-crash4.ll index 69eec7d5f6d8b..c84b5ffbc9edc 100644 --- a/llvm/test/Transforms/JumpThreading/ddt-crash4.ll +++ b/llvm/test/Transforms/JumpThreading/ddt-crash4.ll @@ -3,7 +3,7 @@ @global = external global i64, align 8 -define void @f() { +define void @f(i1 %arg) { ; CHECK-LABEL: @f( ; CHECK-NEXT: bb: ; CHECK-NEXT: br label [[BB1:%.*]] @@ -15,12 +15,28 @@ define void @f() { ; CHECK-NEXT: [[TMP4:%.*]] = load i64, ptr @global, align 8 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[TMP4]], 0 ; CHECK-NEXT: br i1 [[TMP5]], label [[BB23:%.*]], label [[BB23]] -; CHECK: bb23: +; CHECK: bb10: +; CHECK-NEXT: [[TMP11:%.*]] = load i64, ptr @global, align 8 +; CHECK-NEXT: [[TMP12:%.*]] = icmp slt i64 [[TMP11]], 5 +; CHECK-NEXT: br i1 [[TMP12]], label [[BB14:%.*]], label [[BB17:%.*]] +; CHECK: bb14: +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[BB15:%.*]], label [[BB10:%.*]] +; CHECK: bb15: +; CHECK-NEXT: unreachable +; CHECK: bb17: ; CHECK-NEXT: br label [[BB26:%.*]] +; CHECK: bb18: +; CHECK-NEXT: br i1 [[ARG]], label [[BB23]], label [[BB14]] +; CHECK: bb21: +; CHECK-NEXT: br label [[BB26]] +; CHECK: bb23: +; CHECK-NEXT: br i1 [[ARG]], label [[BB24:%.*]], label [[BB14]] +; CHECK: bb24: +; CHECK-NEXT: br i1 [[ARG]], label [[BB28:%.*]], label [[BB21:%.*]] ; CHECK: bb26: ; CHECK-NEXT: br label [[BB1]] ; CHECK: bb27: -; CHECK-NEXT: br label [[BB26]] +; CHECK-NEXT: br label [[BB24]] ; bb: br label %bb1 @@ -52,7 +68,7 @@ bb13: br label %bb14 bb14: - br i1 undef, label %bb15, label %bb16 + br i1 %arg, label %bb15, label %bb16 bb15: unreachable @@ -64,10 +80,10 @@ bb17: br label %bb18 bb18: - br i1 undef, label %bb22, label %bb13 + br i1 %arg, label %bb22, label %bb13 bb19: - br i1 undef, label %bb20, label %bb21 + br i1 %arg, label %bb20, label %bb21 bb20: unreachable @@ -79,10 +95,10 @@ bb22: br label %bb23 bb23: - br i1 undef, label %bb24, label %bb13 + br i1 %arg, label %bb24, label %bb13 bb24: - br i1 undef, label %bb26, label %bb25 + br i1 %arg, label %bb26, label %bb25 bb25: br label %bb19 diff --git a/llvm/test/Transforms/JumpThreading/landing-pad.ll b/llvm/test/Transforms/JumpThreading/landing-pad.ll index 29def94cdda07..9c193cc061b56 100644 --- a/llvm/test/Transforms/JumpThreading/landing-pad.ll +++ b/llvm/test/Transforms/JumpThreading/landing-pad.ll @@ -63,7 +63,7 @@ entry: ret void } -define void @_Z3fn1v() uwtable personality ptr @__gxx_personality_v0 { +define void @_Z3fn1v(i1 %arg) uwtable personality ptr @__gxx_personality_v0 { ; CHECK-LABEL: @_Z3fn1v( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @_Znwm() @@ -93,6 +93,8 @@ define void @_Z3fn1v() uwtable personality ptr @__gxx_personality_v0 { ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[_REF_I_I_I]], align 4 ; CHECK-NEXT: [[TOBOOL_I_I_I:%.*]] = icmp eq i32 [[TMP3]], 0 ; CHECK-NEXT: br i1 [[TOBOOL_I_I_I]], label [[_ZN1BI1DED1EV_EXIT:%.*]], label [[DELETE_NOTNULL_I_I_I:%.*]] +; CHECK: if.then.i.i.i: +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[_ZN1BI1DED1EV_EXIT]], label [[DELETE_NOTNULL_I_I_I1:%.*]] ; CHECK: delete.notnull.i.i.i: ; CHECK-NEXT: call void @_ZdlPv() ; CHECK-NEXT: unreachable @@ -138,7 +140,7 @@ lpad1: ; preds = %_ZN1DC1Ev.exit, %_Z br i1 %tobool.i.i.i, label %_ZN1BI1DED1Ev.exit, label %if.then.i.i.i if.then.i.i.i: ; preds = %lpad1 - br i1 undef, label %_ZN1BI1DED1Ev.exit, label %delete.notnull.i.i.i + br i1 %arg, label %_ZN1BI1DED1Ev.exit, label %delete.notnull.i.i.i delete.notnull.i.i.i: ; preds = %if.then.i.i.i call void @_ZdlPv() #9 @@ -191,7 +193,7 @@ entry: declare void @_ZN1D16deleteKeyPressedEv() -define void @_ZN1BI1DED1Ev(ptr nocapture readonly %this) unnamed_addr uwtable align 2 { +define void @_ZN1BI1DED1Ev(ptr nocapture readonly %this, i1 %arg) unnamed_addr uwtable align 2 { ; CHECK-LABEL: @_ZN1BI1DED1Ev( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[THIS:%.*]], align 8 @@ -199,6 +201,8 @@ define void @_ZN1BI1DED1Ev(ptr nocapture readonly %this) unnamed_addr uwtable al ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[_REF_I_I]], align 4 ; CHECK-NEXT: [[TOBOOL_I_I:%.*]] = icmp eq i32 [[TMP1]], 0 ; CHECK-NEXT: br i1 [[TOBOOL_I_I]], label [[_ZN1BI1DED2EV_EXIT:%.*]], label [[DELETE_NOTNULL_I_I:%.*]] +; CHECK: if.then.i.i: +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[_ZN1BI1DED2EV_EXIT]], label [[DELETE_NOTNULL_I_I1:%.*]] ; CHECK: delete.notnull.i.i: ; CHECK-NEXT: call void @_ZdlPv() ; CHECK-NEXT: unreachable @@ -213,7 +217,7 @@ entry: br i1 %tobool.i.i, label %_ZN1BI1DED2Ev.exit, label %if.then.i.i if.then.i.i: ; preds = %entry - br i1 undef, label %_ZN1BI1DED2Ev.exit, label %delete.notnull.i.i + br i1 %arg, label %_ZN1BI1DED2Ev.exit, label %delete.notnull.i.i delete.notnull.i.i: ; preds = %if.then.i.i call void @_ZdlPv() #9 @@ -225,7 +229,7 @@ _ZN1BI1DED2Ev.exit: ; preds = %entry, %if.then.i.i declare hidden void @__clang_call_terminate() -define void @_ZN1BI1DED2Ev(ptr nocapture readonly %this) unnamed_addr uwtable align 2 { +define void @_ZN1BI1DED2Ev(ptr nocapture readonly %this, i1 %arg) unnamed_addr uwtable align 2 { ; CHECK-LABEL: @_ZN1BI1DED2Ev( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[THIS:%.*]], align 8 @@ -233,6 +237,8 @@ define void @_ZN1BI1DED2Ev(ptr nocapture readonly %this) unnamed_addr uwtable al ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[_REF_I]], align 4 ; CHECK-NEXT: [[TOBOOL_I:%.*]] = icmp eq i32 [[TMP1]], 0 ; CHECK-NEXT: br i1 [[TOBOOL_I]], label [[_ZN1AI1CE5DEREFEV_EXIT:%.*]], label [[DELETE_NOTNULL_I:%.*]] +; CHECK: if.then.i: +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[_ZN1AI1CE5DEREFEV_EXIT]], label [[DELETE_NOTNULL_I1:%.*]] ; CHECK: delete.notnull.i: ; CHECK-NEXT: call void @_ZdlPv() ; CHECK-NEXT: unreachable @@ -247,7 +253,7 @@ entry: br i1 %tobool.i, label %_ZN1AI1CE5derefEv.exit, label %if.then.i if.then.i: ; preds = %entry - br i1 undef, label %_ZN1AI1CE5derefEv.exit, label %delete.notnull.i + br i1 %arg, label %_ZN1AI1CE5derefEv.exit, label %delete.notnull.i delete.notnull.i: ; preds = %if.then.i call void @_ZdlPv() #9 @@ -257,12 +263,14 @@ _ZN1AI1CE5derefEv.exit: ; preds = %entry, %if.then.i ret void } -define void @_ZN1AI1CE5derefEv(ptr nocapture readonly %this) nounwind uwtable align 2 { +define void @_ZN1AI1CE5derefEv(ptr nocapture readonly %this, i1 %arg) nounwind uwtable align 2 { ; CHECK-LABEL: @_ZN1AI1CE5derefEv( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[THIS:%.*]], align 4 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[DELETE_NOTNULL:%.*]] +; CHECK: if.then: +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[IF_END]], label [[DELETE_NOTNULL1:%.*]] ; CHECK: delete.notnull: ; CHECK-NEXT: call void @_ZdlPv() ; CHECK-NEXT: unreachable @@ -275,7 +283,7 @@ entry: br i1 %tobool, label %if.end, label %if.then if.then: ; preds = %entry - br i1 undef, label %if.end, label %delete.notnull + br i1 %arg, label %if.end, label %delete.notnull delete.notnull: ; preds = %if.then call void @_ZdlPv() #9 diff --git a/llvm/test/Transforms/JumpThreading/pr22086.ll b/llvm/test/Transforms/JumpThreading/pr22086.ll index c7f9fcdbd3462..44ab88bb3ea5c 100644 --- a/llvm/test/Transforms/JumpThreading/pr22086.ll +++ b/llvm/test/Transforms/JumpThreading/pr22086.ll @@ -3,12 +3,15 @@ -define void @f() { -; CHECK-LABEL: define void @f() { +define void @f(i1 %arg) { +; CHECK-LABEL: define void @f( +; CHECK-SAME: i1 [[ARG:%.*]]) { ; CHECK-NEXT: [[ENTRY:.*:]] -; CHECK-NEXT: br label %[[LOR_RHS:.*]] +; CHECK-NEXT: br label %[[FOR_COND1:.*]] +; CHECK: [[FOR_COND1]]: +; CHECK-NEXT: br i1 [[ARG]], label %[[LOR_RHS:.*]], label %[[LOR_RHS]] ; CHECK: [[LOR_RHS]]: -; CHECK-NEXT: br label %[[LOR_RHS]] +; CHECK-NEXT: br label %[[FOR_COND1]] ; entry: br label %for.cond1 @@ -23,7 +26,7 @@ if.end16: for.cond1: %g.1 = phi i32 [ 0, %entry ], [ 0, %lor.rhs ], [ %g.3, %if.end16 ] - br i1 undef, label %lor.rhs, label %if.end16 + br i1 %arg, label %lor.rhs, label %if.end16 lor.rhs: br label %for.cond1 diff --git a/llvm/test/Transforms/JumpThreading/pr9331.ll b/llvm/test/Transforms/JumpThreading/pr9331.ll index 572b1e558e059..06c0a42bd849a 100644 --- a/llvm/test/Transforms/JumpThreading/pr9331.ll +++ b/llvm/test/Transforms/JumpThreading/pr9331.ll @@ -13,17 +13,16 @@ entry: for.cond2: ; preds = %for.inc46, %lor.end, %entry %p_44.addr.1 = phi i8 [ %p_44.addr.1, %lor.end ], [ %p_44, %entry ], [ %p_44.addr.1, %for.inc46 ] - br i1 undef, label %for.inc46, label %for.body5 + br i1 true, label %for.inc46, label %for.body5 for.body5: ; preds = %for.cond2 - br i1 undef, label %lbl_465, label %if.then9 + br i1 false, label %lbl_465, label %if.then9 if.then9: ; preds = %for.body5 br label %return lbl_465: ; preds = %lbl_465, %for.body5 - %tobool19 = icmp eq i8 undef, 0 - br i1 %tobool19, label %if.end21, label %lbl_465 + br i1 true, label %if.end21, label %lbl_465 if.end21: ; preds = %lbl_465 %conv23 = zext i8 %p_44.addr.1 to i64 diff --git a/llvm/test/Transforms/JumpThreading/preserving-debugloc-br.ll b/llvm/test/Transforms/JumpThreading/preserving-debugloc-br.ll index ca67f0dec31ba..521c697c71208 100644 --- a/llvm/test/Transforms/JumpThreading/preserving-debugloc-br.ll +++ b/llvm/test/Transforms/JumpThreading/preserving-debugloc-br.ll @@ -24,11 +24,10 @@ lor.rhs: ; preds = %entry br label %lor.end, !dbg !10 lor.end: ; preds = %lor.rhs, %entry - %cmp103 = xor i1 undef, undef, !dbg !11 - br i1 %cmp103, label %for.cond, label %if.then, !dbg !12 + br i1 false, label %for.cond, label %if.then, !dbg !12 for.cond: ; preds = %for.body, %lor.end - br i1 undef, label %if.then, label %for.body, !dbg !13 + br i1 false, label %if.then, label %for.body, !dbg !13 for.body: ; preds = %for.cond br label %for.cond, !dbg !14 diff --git a/llvm/test/Transforms/JumpThreading/unreachable-loops.ll b/llvm/test/Transforms/JumpThreading/unreachable-loops.ll index 7b0dc4ad3ae78..ea0b6fc7d1f89 100644 --- a/llvm/test/Transforms/JumpThreading/unreachable-loops.ll +++ b/llvm/test/Transforms/JumpThreading/unreachable-loops.ll @@ -5,11 +5,11 @@ ; in jump-threading when it tries to update the predecessors' ; profile metadata from a phi node. -define void @unreachable_single_bb_loop() { +define void @unreachable_single_bb_loop(i1 %arg) { ; ; CHECK-LABEL: @unreachable_single_bb_loop( ; CHECK-NEXT: bb: -; CHECK-NEXT: [[TMP:%.*]] = call i32 @a() +; CHECK-NEXT: [[TMP:%.*]] = call i32 @a(i1 %arg) ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP]], 1 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB8:%.*]], label [[BB8]] ; CHECK: bb2: @@ -22,7 +22,7 @@ define void @unreachable_single_bb_loop() { ; CHECK-NEXT: ret void ; bb: - %tmp = call i32 @a() + %tmp = call i32 @a(i1 %arg) %tmp1 = icmp eq i32 %tmp, 1 br i1 %tmp1, label %bb5, label %bb8 @@ -45,11 +45,11 @@ bb8: ; preds = %bb8, %bb7, %bb5, %b ret void } -define void @unreachable_multi_bbs_loop() { +define void @unreachable_multi_bbs_loop(i1 %arg) { ; ; CHECK-LABEL: @unreachable_multi_bbs_loop( ; CHECK-NEXT: bb: -; CHECK-NEXT: [[TMP:%.*]] = call i32 @a() +; CHECK-NEXT: [[TMP:%.*]] = call i32 @a(i1 %arg) ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP]], 1 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB8:%.*]], label [[BB8]] ; CHECK: bb3: @@ -64,7 +64,7 @@ define void @unreachable_multi_bbs_loop() { ; CHECK-NEXT: ret void ; bb: - %tmp = call i32 @a() + %tmp = call i32 @a(i1 %arg) %tmp1 = icmp eq i32 %tmp, 1 br i1 %tmp1, label %bb5, label %bb8 @@ -89,12 +89,12 @@ bb7: ; preds = %bb5 bb8: ; preds = %bb8, %bb7, %bb5, %bb2 ret void } -declare i32 @a() +declare i32 @a(i1 %arg) ; This gets into a state that could cause instruction simplify ; to hang - an insertelement instruction has itself as an operand. -define void @PR48362() { +define void @PR48362(i1 %arg) { ; ; CHECK-LABEL: @PR48362( ; CHECK-NEXT: cleanup.cont1500: @@ -142,7 +142,7 @@ for.body1911: ; preds = %if.else1904 br label %land.end2173 land.end2173: ; preds = %for.body1911 - br i1 undef, label %if.end2178, label %cleanup2297 + br i1 %arg, label %if.end2178, label %cleanup2297 if.end2178: ; preds = %land.end2173 %l_580.sroa.0.2.vec.insert = insertelement <4 x i32> %l_580.sroa.0.0, i32 undef, i32 1 @@ -165,7 +165,7 @@ cleanup.cont2339: ; preds = %cleanup2329 br label %for.inc2340 for.inc2340: ; preds = %cleanup.cont2339 - br i1 undef, label %for.body1509, label %crit_edge115 + br i1 %arg, label %for.body1509, label %crit_edge115 crit_edge114: ; preds = %cleanup2329 unreachable From 0ba38260d2f09bf42bca356914e58990ba7b46df Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 18 Nov 2024 16:33:10 -0700 Subject: [PATCH 2/6] Remove br i1 undef in LCSSA directory --- llvm/test/Transforms/LCSSA/indirectbr.ll | 18 +++++++++--------- llvm/test/Transforms/LCSSA/invoke-dest.ll | 18 +++++++++--------- llvm/test/Transforms/LCSSA/pr28424.ll | 18 +++++++++--------- llvm/test/Transforms/LCSSA/pr28608.ll | 6 +++--- llvm/test/Transforms/LCSSA/remove-phis.ll | 18 +++++++++--------- llvm/test/Transforms/LCSSA/unused-phis.ll | 8 ++++---- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/llvm/test/Transforms/LCSSA/indirectbr.ll b/llvm/test/Transforms/LCSSA/indirectbr.ll index 7ddfb6bfb223d..a71696c091a69 100644 --- a/llvm/test/Transforms/LCSSA/indirectbr.ll +++ b/llvm/test/Transforms/LCSSA/indirectbr.ll @@ -4,25 +4,25 @@ ; the loop, and the loop has exits with predecessors not within the loop ; (and btw these edges are unsplittable due to the indirectbr). ; PR5437 -define i32 @test0() nounwind { +define i32 @test0(i1 %arg) nounwind { ; CHECK-LABEL: @test0 entry: - br i1 undef, label %"4", label %"3" + br i1 %arg, label %"4", label %"3" "3": ; preds = %entry ret i32 0 "4": ; preds = %entry - br i1 undef, label %"6", label %"5" + br i1 %arg, label %"6", label %"5" "5": ; preds = %"4" unreachable "6": ; preds = %"4" - br i1 undef, label %"10", label %"13" + br i1 %arg, label %"10", label %"13" "10": ; preds = %"6" - br i1 undef, label %"22", label %"15" + br i1 %arg, label %"22", label %"15" "13": ; preds = %"6" unreachable @@ -393,7 +393,7 @@ entry: unreachable "1566": ; preds = %"23" - br i1 undef, label %"1569", label %"1568" + br i1 %arg, label %"1569", label %"1568" "1568": ; preds = %"1566" unreachable @@ -545,13 +545,13 @@ entry: ; create PHIs in one of such exits we are also inserting PHIs in L2 header. This ; could break LCSSA form for L2 because these inserted PHIs can also have uses ; in L2 exits. Test that we don't assert/crash on that. -define void @test1() { +define void @test1(i1 %arg) { ; CHECK-LABEL: @test1 br label %lab1 lab1: %tmp21 = add i32 undef, 677038203 - br i1 undef, label %lab2, label %exit + br i1 %arg, label %lab2, label %exit lab2: indirectbr ptr undef, [label %lab1, label %lab3] @@ -559,7 +559,7 @@ lab2: lab3: ; CHECK: %tmp21.lcssa1 = phi i32 [ %tmp21.lcssa1, %lab4 ], [ %tmp21, %lab2 ] %tmp12 = phi i32 [ %tmp21, %lab2 ], [ %tmp12, %lab4 ] - br i1 undef, label %lab5, label %lab4 + br i1 %arg, label %lab5, label %lab4 lab4: br label %lab3 diff --git a/llvm/test/Transforms/LCSSA/invoke-dest.ll b/llvm/test/Transforms/LCSSA/invoke-dest.ll index 88f5688e14af1..ea7e5f31ec0ae 100644 --- a/llvm/test/Transforms/LCSSA/invoke-dest.ll +++ b/llvm/test/Transforms/LCSSA/invoke-dest.ll @@ -9,9 +9,9 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3 @.str32190 = external constant [92 x i8], align 1 ; [#uses=1] @.str41 = external constant [25 x i8], align 1 ; [#uses=1] -define void @_ZN8EtherBus10initializeEv() personality ptr @__gxx_personality_v0 { +define void @_ZN8EtherBus10initializeEv(i1 %arg) personality ptr @__gxx_personality_v0 { entry: - br i1 undef, label %_ZN7cObjectnwEj.exit, label %bb.i + br i1 %arg, label %_ZN7cObjectnwEj.exit, label %bb.i bb.i: ; preds = %entry br label %_ZN7cObjectnwEj.exit @@ -21,19 +21,19 @@ _ZN7cObjectnwEj.exit: ; preds = %bb.i, %entry to label %bb1 unwind label %lpad bb1: ; preds = %_ZN7cObjectnwEj.exit - br i1 undef, label %_ZNK5cGate4sizeEv.exit, label %bb.i110 + br i1 %arg, label %_ZNK5cGate4sizeEv.exit, label %bb.i110 bb.i110: ; preds = %bb1 br label %_ZNK5cGate4sizeEv.exit _ZNK5cGate4sizeEv.exit: ; preds = %bb.i110, %bb1 - br i1 undef, label %_ZNK5cGate4sizeEv.exit122, label %bb.i120 + br i1 %arg, label %_ZNK5cGate4sizeEv.exit122, label %bb.i120 bb.i120: ; preds = %_ZNK5cGate4sizeEv.exit br label %_ZNK5cGate4sizeEv.exit122 _ZNK5cGate4sizeEv.exit122: ; preds = %bb.i120, %_ZNK5cGate4sizeEv.exit - br i1 undef, label %bb8, label %bb2 + br i1 %arg, label %bb8, label %bb2 bb2: ; preds = %_ZNK5cGate4sizeEv.exit122 unreachable @@ -51,7 +51,7 @@ invcont10: ; preds = %invcont9 to label %invcont11 unwind label %lpad119 invcont11: ; preds = %invcont10 - br i1 undef, label %bb12, label %bb18 + br i1 %arg, label %bb12, label %bb18 bb12: ; preds = %invcont11 invoke void (ptr, ptr, ...) @_ZN6cEnvir6printfEPKcz(ptr null, ptr @.str12, i32 undef) @@ -61,10 +61,10 @@ bb.i.i159: ; preds = %bb12 unreachable bb18: ; preds = %invcont11 - br i1 undef, label %bb32, label %bb34 + br i1 %arg, label %bb32, label %bb34 bb32: ; preds = %bb18 - br i1 undef, label %bb.i.i123, label %bb34 + br i1 %arg, label %bb.i.i123, label %bb34 bb.i.i123: ; preds = %bb32 br label %bb34 @@ -74,7 +74,7 @@ bb34: ; preds = %bb.i.i123, %bb32, %bb18 to label %invcont35 unwind label %lpad119 ; [#uses=0] invcont35: ; preds = %bb34 - br i1 undef, label %bb49, label %bb61 + br i1 %arg, label %bb49, label %bb61 bb49: ; preds = %invcont35 invoke void (ptr, ptr, ...) @_ZNK13cSimpleModule5errorEPKcz(ptr undef, ptr @.str32190) diff --git a/llvm/test/Transforms/LCSSA/pr28424.ll b/llvm/test/Transforms/LCSSA/pr28424.ll index 42d8de19e9148..3f247a2023722 100644 --- a/llvm/test/Transforms/LCSSA/pr28424.ll +++ b/llvm/test/Transforms/LCSSA/pr28424.ll @@ -8,19 +8,19 @@ target triple = "x86_64-unknown-linux-gnu" ; it. ; CHECK-LABEL: @foo1 -define internal i32 @foo1() { +define internal i32 @foo1(i1 %arg) { entry: br label %header header: %x = add i32 0, 1 - br i1 undef, label %if, label %loopexit1 + br i1 %arg, label %if, label %loopexit1 if: - br i1 undef, label %latch, label %loopexit2 + br i1 %arg, label %latch, label %loopexit2 latch: - br i1 undef, label %header, label %loopexit3 + br i1 %arg, label %header, label %loopexit3 ; CHECK: loopexit1: ; CHECK: %x.lcssa = phi i32 [ %x, %header ] @@ -40,7 +40,7 @@ loopexit3: ; CHECK: loop_with_insert_point: ; CHECK: %x4 = phi i32 [ %x4, %loop_with_insert_point ], [ %x.lcssa2, %loopexit3 ], [ %x.lcssa, %loopexit1 ] loop_with_insert_point: - br i1 undef, label %loop_with_insert_point, label %bb + br i1 %arg, label %loop_with_insert_point, label %bb ; CHECK: bb: ; CHECK: %x4.lcssa = phi i32 [ %x4, %loop_with_insert_point ] @@ -54,16 +54,16 @@ exit: } ; CHECK-LABEL: @foo2 -define internal i32 @foo2() { +define internal i32 @foo2(i1 %arg) { entry: br label %header header: %x = add i32 0, 1 - br i1 undef, label %latch, label %loopexit1 + br i1 %arg, label %latch, label %loopexit1 latch: - br i1 undef, label %header, label %loopexit2 + br i1 %arg, label %header, label %loopexit2 ; CHECK: loopexit1: ; CHECK: %x.lcssa = phi i32 [ %x, %header ] @@ -78,7 +78,7 @@ loopexit2: ; CHECK: loop_with_insert_point: ; CHECK: %x2 = phi i32 [ %x2, %loop_with_insert_point ], [ %x.lcssa1, %loopexit2 ], [ %x.lcssa, %loopexit1 ] loop_with_insert_point: - br i1 undef, label %loop_with_insert_point, label %exit + br i1 %arg, label %loop_with_insert_point, label %exit ; CHECK: exit: ; CHECK: %x2.lcssa = phi i32 [ %x2, %loop_with_insert_point ] diff --git a/llvm/test/Transforms/LCSSA/pr28608.ll b/llvm/test/Transforms/LCSSA/pr28608.ll index 0b0fb664092d0..b522bea806d22 100644 --- a/llvm/test/Transforms/LCSSA/pr28608.ll +++ b/llvm/test/Transforms/LCSSA/pr28608.ll @@ -5,7 +5,7 @@ target triple = "x86_64-unknown-linux-gnu" ; PR28608 ; Check that we don't crash on this test. -define void @foo() { +define void @foo(i1 %arg) { entry: br label %bb1 @@ -14,10 +14,10 @@ bb1: bb2: %x = phi i32 [ undef, %bb5 ], [ undef, %bb1 ] - br i1 undef, label %bb3, label %bb6 + br i1 %arg, label %bb3, label %bb6 bb3: - br i1 undef, label %bb5, label %bb4 + br i1 %arg, label %bb5, label %bb4 bb4: br label %bb6 diff --git a/llvm/test/Transforms/LCSSA/remove-phis.ll b/llvm/test/Transforms/LCSSA/remove-phis.ll index 67e9a035cad79..8b669a29c2de9 100644 --- a/llvm/test/Transforms/LCSSA/remove-phis.ll +++ b/llvm/test/Transforms/LCSSA/remove-phis.ll @@ -3,37 +3,37 @@ ; This bugpoint reduced test case used to assert when removing unused PHI nodes. ; Just verify that we do not assert/crash. -define void @test() { +define void @test(i1 %arg) { entry: br label %gazank gazank: %value = phi i16 [ 0, %entry ], [ undef, %gazonk ] - br i1 undef, label %gazink, label %qqq + br i1 %arg, label %gazink, label %qqq gazink: - br i1 undef, label %gazonk, label %infinite.loop.pred + br i1 %arg, label %gazonk, label %infinite.loop.pred gazonk: - br i1 undef, label %exit1, label %gazank + br i1 %arg, label %exit1, label %gazank qqq: - br i1 undef, label %www, label %exit2 + br i1 %arg, label %www, label %exit2 www: - br i1 undef, label %qqq, label %foo.pred + br i1 %arg, label %qqq, label %foo.pred foo.pred: br label %foo foo: - br i1 undef, label %bar, label %exit1.pred + br i1 %arg, label %bar, label %exit1.pred bar: - br i1 undef, label %foo, label %exit2.pred + br i1 %arg, label %foo, label %exit2.pred unreachable1: - br i1 undef, label %foo, label %exit2.pred + br i1 %arg, label %foo, label %exit2.pred exit1.pred: br label %exit1 diff --git a/llvm/test/Transforms/LCSSA/unused-phis.ll b/llvm/test/Transforms/LCSSA/unused-phis.ll index 1a5f27e550315..baead279c86f9 100644 --- a/llvm/test/Transforms/LCSSA/unused-phis.ll +++ b/llvm/test/Transforms/LCSSA/unused-phis.ll @@ -12,19 +12,19 @@ declare void @printf(i32 %i) -define i32 @unused_phis() nounwind { +define i32 @unused_phis(i1 %arg) nounwind { entry: br label %loop loop: %i = phi i32 [0, %entry], [1, %then2] - br i1 undef, label %exit1, label %then1 + br i1 %arg, label %exit1, label %then1 then1: - br i1 undef, label %exit2, label %then2 + br i1 %arg, label %exit2, label %then2 then2: - br i1 undef, label %exit3, label %loop + br i1 %arg, label %exit3, label %loop exit1: call void @printf(i32 %i) From 91bd34fe574bc4369cd250c9b512ab1dc1ecdf63 Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 18 Nov 2024 20:30:53 -0700 Subject: [PATCH 3/6] Remove br i1 undef in LICM directory --- .../LICM/2009-12-10-LICM-Indbr-Crash.ll | 10 +-- .../Transforms/LICM/alias-set-tracker-loss.ll | 4 +- llvm/test/Transforms/LICM/assume.ll | 12 +-- llvm/test/Transforms/LICM/callbr-crash.ll | 6 +- llvm/test/Transforms/LICM/crash.ll | 4 +- llvm/test/Transforms/LICM/debug-value.ll | 12 +-- llvm/test/Transforms/LICM/gc-relocate.ll | 8 +- llvm/test/Transforms/LICM/hoist-phi.ll | 82 +++++++++---------- .../Transforms/LICM/lcssa-ssa-promoter.ll | 18 ++-- llvm/test/Transforms/LICM/loopsink-pr39570.ll | 6 +- .../LICM/outer-loop-deleted-before-licm.ll | 2 +- llvm/test/Transforms/LICM/pr32129.ll | 13 ++- llvm/test/Transforms/LICM/pr37323.ll | 10 +-- llvm/test/Transforms/LICM/pr38513.ll | 6 +- llvm/test/Transforms/LICM/pr50367.ll | 6 +- llvm/test/Transforms/LICM/sink-promote.ll | 12 +-- llvm/test/Transforms/LICM/sinking.ll | 20 ++--- 17 files changed, 118 insertions(+), 113 deletions(-) diff --git a/llvm/test/Transforms/LICM/2009-12-10-LICM-Indbr-Crash.ll b/llvm/test/Transforms/LICM/2009-12-10-LICM-Indbr-Crash.ll index 9fded3277fdb4..10b2d7331b5b4 100644 --- a/llvm/test/Transforms/LICM/2009-12-10-LICM-Indbr-Crash.ll +++ b/llvm/test/Transforms/LICM/2009-12-10-LICM-Indbr-Crash.ll @@ -1,18 +1,18 @@ ; Test for rdar://7452967 ; RUN: opt < %s -passes=licm -disable-output -define void @foo (ptr %v) +define void @foo (ptr %arg) { entry: - br i1 undef, label %preheader, label %return + br i1 false, label %preheader, label %return preheader: - br i1 undef, label %loop, label %return + br i1 false, label %loop, label %return loop: - indirectbr ptr undef, [label %preheader, label %stuff] + indirectbr ptr %arg, [label %preheader, label %stuff] stuff: - %0 = load i8, ptr undef, align 1 + %0 = load i8, ptr %arg, align 1 br label %loop return: diff --git a/llvm/test/Transforms/LICM/alias-set-tracker-loss.ll b/llvm/test/Transforms/LICM/alias-set-tracker-loss.ll index ff8d758d05ae6..1670d865e89dd 100644 --- a/llvm/test/Transforms/LICM/alias-set-tracker-loss.ll +++ b/llvm/test/Transforms/LICM/alias-set-tracker-loss.ll @@ -6,7 +6,7 @@ ; removed, its alias set tracker is destroyed and no longer available when LICM ; runs on the outer loop. -define void @f() { +define void @f(i1 %arg) { entry: br label %l1 @@ -17,7 +17,7 @@ l1.loopexit: br label %l1.backedge l1: - br i1 undef, label %l1.backedge, label %l2.preheader + br i1 %arg, label %l1.backedge, label %l2.preheader l1.backedge: br label %l1 diff --git a/llvm/test/Transforms/LICM/assume.ll b/llvm/test/Transforms/LICM/assume.ll index bfb0359dbdff0..0a00f1ef7def5 100644 --- a/llvm/test/Transforms/LICM/assume.ll +++ b/llvm/test/Transforms/LICM/assume.ll @@ -1,19 +1,19 @@ ; RUN: opt -passes=licm < %s -S | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop-mssa(licm)' < %s -S | FileCheck %s -define void @f_0(i1 %p) nounwind ssp { +define void @f_0(i1 %p, i1 %arg) nounwind ssp { ; CHECK-LABEL: @f_0( entry: br label %for.body for.body: - br i1 undef, label %if.then, label %for.cond.backedge + br i1 %arg, label %if.then, label %for.cond.backedge for.cond.backedge: - br i1 undef, label %for.end104, label %for.body + br i1 %arg, label %for.end104, label %for.body if.then: - br i1 undef, label %if.then27, label %if.end.if.end.split_crit_edge.critedge + br i1 %arg, label %if.then27, label %if.end.if.end.split_crit_edge.critedge if.then27: ; CHECK: tail call void @llvm.assume @@ -24,10 +24,10 @@ if.end.if.end.split_crit_edge.critedge: br label %for.body61 for.body61.us: - br i1 undef, label %for.cond.backedge, label %for.body61.us + br i1 %arg, label %for.cond.backedge, label %for.body61.us for.body61: - br i1 undef, label %for.cond.backedge, label %for.body61 + br i1 %arg, label %for.cond.backedge, label %for.body61 for.end104: ret void diff --git a/llvm/test/Transforms/LICM/callbr-crash.ll b/llvm/test/Transforms/LICM/callbr-crash.ll index 60f7f6c7dd768..1bc60e575663b 100644 --- a/llvm/test/Transforms/LICM/callbr-crash.ll +++ b/llvm/test/Transforms/LICM/callbr-crash.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -passes=licm < %s | FileCheck %s -define i32 @j() { +define i32 @j(i1 %arg) { ; CHECK-LABEL: @j( ; CHECK-NEXT: entry: ; CHECK-NEXT: br label [[FOR_COND:%.*]] @@ -9,7 +9,7 @@ define i32 @j() { ; CHECK-NEXT: callbr void asm sideeffect "", "!i,~{dirflag},~{fpsr},~{flags}"() ; CHECK-NEXT: to label [[COND_TRUE_I:%.*]] [label %for.end.split.loop.exit1] ; CHECK: cond.true.i: -; CHECK-NEXT: br i1 true, label [[FOR_END_SPLIT_LOOP_EXIT:%.*]], label [[FOR_COND]] +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[FOR_END_SPLIT_LOOP_EXIT:%.*]], label [[FOR_COND]] ; CHECK: for.end.split.loop.exit: ; CHECK-NEXT: [[ASMRESULT1_I_I_LE:%.*]] = extractvalue { i8, i32 } zeroinitializer, 1 ; CHECK-NEXT: br label [[FOR_END:%.*]] @@ -29,7 +29,7 @@ for.cond: ; preds = %cond.true.i, %entry cond.true.i: ; preds = %for.cond %asmresult1.i.i = extractvalue { i8, i32 } zeroinitializer, 1 - br i1 undef, label %for.end, label %for.cond + br i1 %arg, label %for.end, label %for.cond for.end: ; preds = %cond.true.i, %for.cond %phi = phi i32 [ %asmresult1.i.i, %cond.true.i ], [ undef, %for.cond ] diff --git a/llvm/test/Transforms/LICM/crash.ll b/llvm/test/Transforms/LICM/crash.ll index 2cb44daf8e24f..03fc39b77a5a5 100644 --- a/llvm/test/Transforms/LICM/crash.ll +++ b/llvm/test/Transforms/LICM/crash.ll @@ -42,10 +42,10 @@ for.body: ; preds = %for.body, %entry } ; PR8102 -define void @test3() { +define void @test3(i1 %arg) { entry: %__first = alloca { ptr } - br i1 undef, label %for.cond, label %for.end + br i1 %arg, label %for.cond, label %for.end for.cond: ; preds = %for.cond, %entry %tmp2 = load ptr, ptr %__first, align 4 diff --git a/llvm/test/Transforms/LICM/debug-value.ll b/llvm/test/Transforms/LICM/debug-value.ll index 17ad57f58898d..cbbfbe6c3beb8 100644 --- a/llvm/test/Transforms/LICM/debug-value.ll +++ b/llvm/test/Transforms/LICM/debug-value.ll @@ -3,18 +3,18 @@ ; RUN: opt -passes=licm < %s -S --try-experimental-debuginfo-iterators | FileCheck %s -define void @dgefa() nounwind ssp { +define void @dgefa(i1 %arg) nounwind ssp { entry: br label %for.body for.body: ; preds = %for.cond.backedge, %entry - br i1 undef, label %if.then, label %for.cond.backedge, !dbg !11 + br i1 %arg, label %if.then, label %for.cond.backedge, !dbg !11 for.cond.backedge: ; preds = %for.body61, %for.body61.us, %for.body - br i1 undef, label %for.end104, label %for.body, !dbg !15 + br i1 %arg, label %for.end104, label %for.body, !dbg !15 if.then: ; preds = %for.body - br i1 undef, label %if.then27, label %if.end.if.end.split_crit_edge.critedge, !dbg !16 + br i1 %arg, label %if.then27, label %if.end.if.end.split_crit_edge.critedge, !dbg !16 if.then27: ; preds = %if.then ; CHECK: #dbg_value @@ -25,10 +25,10 @@ if.end.if.end.split_crit_edge.critedge: ; preds = %if.then br label %for.body61 for.body61.us: ; preds = %for.body61.us, %if.then27 - br i1 undef, label %for.cond.backedge, label %for.body61.us, !dbg !23 + br i1 %arg, label %for.cond.backedge, label %for.body61.us, !dbg !23 for.body61: ; preds = %for.body61, %if.end.if.end.split_crit_edge.critedge - br i1 undef, label %for.cond.backedge, label %for.body61, !dbg !23 + br i1 %arg, label %for.cond.backedge, label %for.body61, !dbg !23 for.end104: ; preds = %for.cond.backedge ret void, !dbg !24 diff --git a/llvm/test/Transforms/LICM/gc-relocate.ll b/llvm/test/Transforms/LICM/gc-relocate.ll index 2149e74b7ab0d..69b16a9b94d4d 100644 --- a/llvm/test/Transforms/LICM/gc-relocate.ll +++ b/llvm/test/Transforms/LICM/gc-relocate.ll @@ -4,15 +4,15 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2" target triple = "x86_64-unknown-linux-gnu" -define ptr addrspace(1) @test(ptr addrspace(1) %arg) #0 gc "statepoint-example" personality ptr @wobble { +define ptr addrspace(1) @test(ptr addrspace(1) %arg, i1 %arg2) #0 gc "statepoint-example" personality ptr @wobble { ; CHECK-LABEL: @test( ; CHECK-NEXT: bb: ; CHECK-NEXT: br label [[BB1:%.*]] ; CHECK: bb1: ; CHECK-NEXT: [[TMP:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 1, i32 16, ptr nonnull elementtype(i32 (i32, ptr addrspace(1), i32, i32, i32)) @zot, i32 5, i32 0, i32 undef, ptr addrspace(1) undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0) [ "deopt"(i32 0, i32 0, i32 0, i32 235, i32 3, i32 32, i32 0, i32 0, ptr addrspace(1) undef, i32 3, i32 undef, i32 3, float undef, i32 0, ptr addrspace(1) undef, i32 7, ptr null, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 0, ptr addrspace(1) undef, i32 4, double undef, i32 7, ptr null, i32 0, ptr addrspace(1) undef, i32 3, float undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) null, i32 3, i32 -15108, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ] -; CHECK-NEXT: br i1 false, label [[BB1]], label [[BB2:%.*]] +; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1]], label [[BB2:%.*]] ; CHECK: bb2: -; CHECK-NEXT: [[RES_LE:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[TMP]], i32 0, i32 0) #[[ATTR1:[0-9]+]] +; CHECK-NEXT: [[RES_LE:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[TMP]], i32 0, i32 0) #[[ATTR2:[0-9]+]] ; CHECK-NEXT: ret ptr addrspace(1) [[RES_LE]] ; bb: @@ -21,7 +21,7 @@ bb: bb1: %tmp = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 1, i32 16, ptr nonnull elementtype(i32 (i32, ptr addrspace(1), i32, i32, i32)) @zot, i32 5, i32 0, i32 undef, ptr addrspace(1) undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0) [ "deopt"(i32 0, i32 0, i32 0, i32 235, i32 3, i32 32, i32 0, i32 0, ptr addrspace(1) undef, i32 3, i32 undef, i32 3, float undef, i32 0, ptr addrspace(1) undef, i32 7, ptr null, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 0, ptr addrspace(1) undef, i32 4, double undef, i32 7, ptr null, i32 0, ptr addrspace(1) undef, i32 3, float undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) undef, i32 0, ptr addrspace(1) null, i32 3, i32 -15108, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null, i32 7, ptr null), "gc-live"(ptr addrspace(1) %arg) ] %res = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %tmp, i32 0, i32 0) readnone - br i1 undef, label %bb1, label %bb2 + br i1 %arg2, label %bb1, label %bb2 bb2: ret ptr addrspace(1) %res diff --git a/llvm/test/Transforms/LICM/hoist-phi.ll b/llvm/test/Transforms/LICM/hoist-phi.ll index 4d8752d790737..bf999b98a1dac 100644 --- a/llvm/test/Transforms/LICM/hoist-phi.ll +++ b/llvm/test/Transforms/LICM/hoist-phi.ll @@ -819,7 +819,7 @@ then: ; to check that we have a unique loop preheader when we hoist the store (and so ; don't fail an assertion). ; CHECK-LABEL: @triangles_in_diamond -define void @triangles_in_diamond(ptr %ptr) { +define void @triangles_in_diamond(ptr %ptr, i1 %arg) { ; CHECK-LABEL: entry: ; CHECK: store i32 0, ptr %ptr, align 4 ; CHECK: br label %loop @@ -827,16 +827,16 @@ entry: br label %loop loop: - br i1 undef, label %left_triangle_1, label %right_triangle + br i1 %arg, label %left_triangle_1, label %right_triangle left_triangle_1: - br i1 undef, label %left_triangle_1_if, label %left_triangle_2 + br i1 %arg, label %left_triangle_1_if, label %left_triangle_2 left_triangle_1_if: br label %left_triangle_2 left_triangle_2: - br i1 undef, label %left_triangle_2_if, label %left_triangle_2_then + br i1 %arg, label %left_triangle_2_if, label %left_triangle_2_then left_triangle_2_if: br label %left_triangle_2_then @@ -845,7 +845,7 @@ left_triangle_2_then: br label %loop.end right_triangle: - br i1 undef, label %right_triangle.if, label %right_triangle.then + br i1 %arg, label %right_triangle.if, label %right_triangle.then right_triangle.if: br label %right_triangle.then @@ -860,7 +860,7 @@ loop.end: ; %cmp dominates its used after being hoisted, but not after %brmerge is rehoisted ; CHECK-LABEL: @rehoist -define void @rehoist(ptr %this, i32 %x) { +define void @rehoist(ptr %this, i32 %x, i1 %arg) { ; CHECK-LABEL: entry: ; CHECK-DAG: %sub = add nsw i32 %x, -1 ; CHECK-DAG: %cmp = icmp eq i32 0, %sub @@ -870,7 +870,7 @@ entry: br label %loop loop: - br i1 undef, label %if1, label %else1 + br i1 %arg, label %if1, label %else1 if1: call void %this(ptr %this) @@ -897,7 +897,7 @@ end: ; A test case that uses empty blocks in a way that can cause control flow ; hoisting to get confused. ; CHECK-LABEL: @empty_blocks_multiple_conditional_branches -define void @empty_blocks_multiple_conditional_branches(float %arg, ptr %ptr) { +define void @empty_blocks_multiple_conditional_branches(float %arg, ptr %ptr, i1 %arg2) { ; CHECK-LABEL: entry ; CHECK-DAG: %div1 = fmul float %arg, 4.000000e+00 ; CHECK-DAG: %div2 = fmul float %arg, 2.000000e+00 @@ -910,10 +910,10 @@ entry: ; CHECK: br label %loop loop: - br i1 undef, label %backedge2, label %cond1 + br i1 %arg2, label %backedge2, label %cond1 cond1: - br i1 undef, label %cond1.if, label %cond1.else + br i1 %arg2, label %cond1.if, label %cond1.else cond1.else: br label %cond3 @@ -926,7 +926,7 @@ cond1.if.next: cond2: %div1 = fmul float %arg, 4.000000e+00 - br i1 undef, label %cond2.if, label %cond2.then + br i1 %arg2, label %cond2.if, label %cond2.then cond2.if: br label %cond2.then @@ -939,7 +939,7 @@ cond2.then: br label %backedge2 cond3: - br i1 undef, label %cond3.then, label %cond3.if + br i1 %arg2, label %cond3.then, label %cond3.if cond3.if: %div2 = fmul float %arg, 2.000000e+00 @@ -955,7 +955,7 @@ backedge2: ; We can't do much here, so mainly just check that we don't crash. ; CHECK-LABEL: @many_path_phi -define void @many_path_phi(ptr %ptr1, ptr %ptr2) { +define void @many_path_phi(ptr %ptr1, ptr %ptr2, i1 %arg) { ; CHECK-LABEL: entry: ; CHECK-DAG: %gep3 = getelementptr inbounds i32, ptr %ptr2, i32 2 ; CHECK-DAG: %gep2 = getelementptr inbounds i32, ptr %ptr2, i32 2 @@ -969,7 +969,7 @@ loop: br i1 %cmp1, label %cond2, label %cond1 cond1: - br i1 undef, label %end, label %cond1.else + br i1 %arg, label %end, label %cond1.else cond1.else: %gep2 = getelementptr inbounds i32, ptr %ptr2, i32 2 @@ -981,7 +981,7 @@ cond1.end: br label %end cond2: - br i1 undef, label %end, label %cond2.else + br i1 %arg, label %end, label %cond2.else cond2.else: %gep3 = getelementptr inbounds i32, ptr %ptr2, i32 2 @@ -1000,7 +1000,7 @@ end: ; Check that we correctly handle the hoisting of %gep when theres a critical ; edge that branches to the preheader. ; CHECK-LABEL: @crit_edge -define void @crit_edge(ptr %ptr, i32 %idx, i1 %cond1, i1 %cond2) { +define void @crit_edge(ptr %ptr, i32 %idx, i1 %cond1, i1 %cond2, i1 %arg) { ; CHECK-LABEL: entry: ; CHECK: %gep = getelementptr inbounds i32, ptr %ptr, i32 %idx ; CHECK: br label %preheader @@ -1030,7 +1030,7 @@ crit_edge: ; Check that the conditional sub is correctly hoisted from the inner loop to the ; preheader of the outer loop. ; CHECK-LABEL: @hoist_from_innermost_loop -define void @hoist_from_innermost_loop(i32 %nx, ptr %ptr) { +define void @hoist_from_innermost_loop(i32 %nx, ptr %ptr, i1 %arg) { ; CHECK-LABEL: entry: ; CHECK-DAG: %sub = sub nsw i32 0, %nx ; CHECK: br label %outer_loop @@ -1044,7 +1044,7 @@ middle_loop: br label %inner_loop inner_loop: - br i1 undef, label %inner_loop_end, label %if + br i1 %arg, label %inner_loop_end, label %if if: %sub = sub nsw i32 0, %nx @@ -1052,10 +1052,10 @@ if: br label %inner_loop_end inner_loop_end: - br i1 undef, label %inner_loop, label %middle_loop_end + br i1 %arg, label %inner_loop, label %middle_loop_end middle_loop_end: - br i1 undef, label %middle_loop, label %outer_loop_end + br i1 %arg, label %middle_loop, label %outer_loop_end outer_loop_end: br label %outer_loop @@ -1231,7 +1231,7 @@ end: ; two destinations that are actually the same. We can't hoist this. ; TODO: This could be hoisted by erasing one of the incoming values. ; CHECK-LABEL: @phi_multiple_values_same_block -define i32 @phi_multiple_values_same_block(i32 %arg) { +define i32 @phi_multiple_values_same_block(i32 %arg, i1 %arg2) { ; CHECK-LABEL: entry: ; CHECK: %cmp = icmp sgt i32 %arg, 4 ; CHECK-NOT: phi @@ -1244,11 +1244,11 @@ loop: br i1 %cmp, label %if, label %then if: - br i1 undef, label %then, label %then + br i1 %arg2, label %then, label %then then: %phi = phi i32 [ %arg, %loop ], [ 1, %if ], [ 1, %if ] - br i1 undef, label %exit, label %loop + br i1 %arg2, label %exit, label %loop exit: ret i32 %phi @@ -1379,12 +1379,12 @@ loop.backedge: ; The order that we hoist instructions from the loop is different to the textual ; order in the function. Check that we can rehoist this correctly. ; CHECK-LABEL: @rehoist_wrong_order_1 -define void @rehoist_wrong_order_1(ptr %ptr) { +define void @rehoist_wrong_order_1(ptr %ptr, i1 %arg) { ; CHECK-LABEL: entry ; CHECK-DAG: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 ; CHECK-DAG: %gep3 = getelementptr inbounds i32, ptr %ptr, i64 3 ; CHECK-DAG: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 -; CHECK-ENABLED: br i1 undef, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] entry: br label %loop @@ -1395,7 +1395,7 @@ entry: ; CHECK-ENABLED: br label %[[LOOP_BACKEDGE_LICM]] ; CHECK-ENABLED: [[LOOP_BACKEDGE_LICM]]: -; CHECK-ENABLED: br i1 undef, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] ; CHECK-ENABLED: [[IF3_LICM]]: ; CHECK-ENABLED: br label %[[END_LICM]] @@ -1404,7 +1404,7 @@ entry: ; CHECK: br label %loop loop: - br i1 undef, label %if1, label %else1 + br i1 %arg, label %if1, label %else1 if1: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 @@ -1414,10 +1414,10 @@ if1: else1: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 store i32 0, ptr %gep2, align 4 - br i1 undef, label %if2, label %loop.backedge + br i1 %arg, label %if2, label %loop.backedge if2: - br i1 undef, label %if3, label %end + br i1 %arg, label %if3, label %end if3: %gep3 = getelementptr inbounds i32, ptr %ptr, i64 3 @@ -1433,12 +1433,12 @@ loop.backedge: } ; CHECK-LABEL: @rehoist_wrong_order_2 -define void @rehoist_wrong_order_2(ptr %ptr) { +define void @rehoist_wrong_order_2(ptr %ptr, i1 %arg) { ; CHECK-LABEL: entry ; CHECK-DAG: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 ; CHECK-DAG: %gep3 = getelementptr inbounds i32, ptr %gep2, i64 3 ; CHECK-DAG: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 -; CHECK-ENABLED: br i1 undef, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] entry: br label %loop @@ -1449,7 +1449,7 @@ entry: ; CHECK-ENABLED: br label %[[LOOP_BACKEDGE_LICM]] ; CHECK-ENABLED: [[LOOP_BACKEDGE_LICM]]: -; CHECK-ENABLED: br i1 undef, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] ; CHECK-ENABLED: [[IF3_LICM]]: ; CHECK-ENABLED: br label %[[END_LICM]] @@ -1458,7 +1458,7 @@ entry: ; CHECK: br label %loop loop: - br i1 undef, label %if1, label %else1 + br i1 %arg, label %if1, label %else1 if1: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 @@ -1468,10 +1468,10 @@ if1: else1: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 store i32 0, ptr %gep2, align 4 - br i1 undef, label %if2, label %loop.backedge + br i1 %arg, label %if2, label %loop.backedge if2: - br i1 undef, label %if3, label %end + br i1 %arg, label %if3, label %end if3: %gep3 = getelementptr inbounds i32, ptr %gep2, i64 3 @@ -1486,11 +1486,11 @@ loop.backedge: } ; CHECK-LABEL: @rehoist_wrong_order_3 -define void @rehoist_wrong_order_3(ptr %ptr) { +define void @rehoist_wrong_order_3(ptr %ptr, i1 %arg) { ; CHECK-LABEL: entry ; CHECK-DAG: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 ; CHECK-DAG: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 -; CHECK-ENABLED: br i1 undef, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF1_LICM:.*]], label %[[ELSE1_LICM:.*]] entry: br label %loop @@ -1503,7 +1503,7 @@ entry: ; CHECK-ENABLED: [[IF2_LICM]]: ; CHECK-ENABLED: %phi = phi ptr [ %gep1, %[[IF1_LICM]] ], [ %gep2, %[[ELSE1_LICM]] ] ; CHECK-ENABLED: %gep3 = getelementptr inbounds i32, ptr %phi, i64 3 -; CHECK-ENABLED: br i1 undef, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] +; CHECK-ENABLED: br i1 %arg, label %[[IF3_LICM:.*]], label %[[END_LICM:.*]] ; CHECK-ENABLED: [[IF3_LICM]]: ; CHECK-ENABLED: br label %[[END_LICM]] @@ -1512,7 +1512,7 @@ entry: ; CHECK: br label %loop loop: - br i1 undef, label %if1, label %else1 + br i1 %arg, label %if1, label %else1 if1: %gep1 = getelementptr inbounds i32, ptr %ptr, i64 1 @@ -1522,11 +1522,11 @@ if1: else1: %gep2 = getelementptr inbounds i32, ptr %ptr, i64 2 store i32 0, ptr %gep2, align 4 - br i1 undef, label %if2, label %loop.backedge + br i1 %arg, label %if2, label %loop.backedge if2: %phi = phi ptr [ %gep1, %if1 ], [ %gep2, %else1 ] - br i1 undef, label %if3, label %end + br i1 %arg, label %if3, label %end if3: %gep3 = getelementptr inbounds i32, ptr %phi, i64 3 diff --git a/llvm/test/Transforms/LICM/lcssa-ssa-promoter.ll b/llvm/test/Transforms/LICM/lcssa-ssa-promoter.ll index a68fb0d00af1b..6081040f7cf0e 100644 --- a/llvm/test/Transforms/LICM/lcssa-ssa-promoter.ll +++ b/llvm/test/Transforms/LICM/lcssa-ssa-promoter.ll @@ -11,21 +11,21 @@ target triple = "x86_64-unknown-linux-gnu" @x = common global i32 0, align 4 @y = common global i32 0, align 4 -define void @PR18688() { +define void @PR18688(i1 %arg) { ; CHECK-LABEL: @PR18688( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[RETURN:%.*]], label [[OUTER_PREHEADER:%.*]] +; CHECK-NEXT: br i1 [[ARG:%.*]], label [[RETURN:%.*]], label [[OUTER_PREHEADER:%.*]] ; CHECK: outer.preheader: ; CHECK-NEXT: [[Y_VAL:%.*]] = load i32, ptr @y, align 4 ; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[Y_VAL]], 0 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]] ; CHECK: outer.header: -; CHECK-NEXT: br i1 undef, label [[OUTER_LATCH:%.*]], label [[INNER_PREHEADER:%.*]] +; CHECK-NEXT: br i1 [[ARG]], label [[OUTER_LATCH:%.*]], label [[INNER_PREHEADER:%.*]] ; CHECK: inner.preheader: ; CHECK-NEXT: br label [[INNER_HEADER:%.*]] ; CHECK: inner.header: ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[TMP1:%.*]], [[INNER_LATCH:%.*]] ], [ 0, [[INNER_PREHEADER]] ] -; CHECK-NEXT: br i1 undef, label [[INNER_BODY_RHS:%.*]], label [[INNER_LATCH]] +; CHECK-NEXT: br i1 [[ARG]], label [[INNER_BODY_RHS:%.*]], label [[INNER_LATCH]] ; CHECK: inner.body.rhs: ; CHECK-NEXT: br label [[INNER_LATCH]] ; CHECK: inner.latch: @@ -36,7 +36,7 @@ define void @PR18688() { ; CHECK-NEXT: br label [[OUTER_LATCH]] ; CHECK: outer.latch: ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[DOTLCSSA1]], [[INNER_EXIT]] ], [ 0, [[OUTER_HEADER]] ] -; CHECK-NEXT: br i1 true, label [[OUTER_EXIT:%.*]], label [[OUTER_HEADER]] +; CHECK-NEXT: br i1 [[ARG]], label [[OUTER_EXIT:%.*]], label [[OUTER_HEADER]] ; CHECK: outer.exit: ; CHECK-NEXT: [[DOTLCSSA:%.*]] = phi i32 [ [[TMP2]], [[OUTER_LATCH]] ] ; CHECK-NEXT: store i32 [[DOTLCSSA]], ptr @x, align 4 @@ -46,20 +46,20 @@ define void @PR18688() { ; entry: - br i1 undef, label %return, label %outer.preheader + br i1 %arg, label %return, label %outer.preheader outer.preheader: br label %outer.header outer.header: store i32 0, ptr @x, align 4 - br i1 undef, label %outer.latch, label %inner.preheader + br i1 %arg, label %outer.latch, label %inner.preheader inner.preheader: br label %inner.header inner.header: - br i1 undef, label %inner.body.rhs, label %inner.latch + br i1 %arg, label %inner.body.rhs, label %inner.latch inner.body.rhs: store i32 0, ptr @x, align 4 @@ -74,7 +74,7 @@ inner.exit: br label %outer.latch outer.latch: - br i1 undef, label %outer.exit, label %outer.header + br i1 %arg, label %outer.exit, label %outer.header outer.exit: br label %return diff --git a/llvm/test/Transforms/LICM/loopsink-pr39570.ll b/llvm/test/Transforms/LICM/loopsink-pr39570.ll index 2894abdf71eee..d0e8569af71ce 100644 --- a/llvm/test/Transforms/LICM/loopsink-pr39570.ll +++ b/llvm/test/Transforms/LICM/loopsink-pr39570.ll @@ -39,8 +39,8 @@ %32 = type { ptr } %33 = type <{ %8, ptr, %10, i32, ptr, ptr, ptr, %27, %28, i16, [2 x i8] }> -define dso_local void @pr39570() local_unnamed_addr align 2 personality ptr @__gxx_personality_v0 !prof !1 { - br i1 undef, label %8, label %1, !prof !2 +define dso_local void @pr39570(i1 %arg) local_unnamed_addr align 2 personality ptr @__gxx_personality_v0 !prof !1 { + br i1 %arg, label %8, label %1, !prof !2 ;