[llvm] [llvm] Remove `br i1 undef` from regression tests (PR #117292)

Lee Wei via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 09:37:03 PST 2024


https://github.com/leewei05 updated https://github.com/llvm/llvm-project/pull/117292

>From 8eb66928cdda312ba0b76d938651b4cc346021c8 Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Thu, 21 Nov 2024 20:38:41 -0700
Subject: [PATCH 1/7] Remove br i1 undef in MemCpyOpt directory

---
 .../MemCpyOpt/aa-recursion-assertion-failure.ll        | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/test/Transforms/MemCpyOpt/aa-recursion-assertion-failure.ll b/llvm/test/Transforms/MemCpyOpt/aa-recursion-assertion-failure.ll
index 80fa9b124e59d4..1b997e8c4f884a 100644
--- a/llvm/test/Transforms/MemCpyOpt/aa-recursion-assertion-failure.ll
+++ b/llvm/test/Transforms/MemCpyOpt/aa-recursion-assertion-failure.ll
@@ -6,7 +6,7 @@ source_filename = "test.cpp"
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64-unknown-linux-android21"
 
-define dso_local void @_Z1ml(i64 %e) {
+define dso_local void @_Z1ml(i64 %e, i1 %arg) {
 ; CHECK-LABEL: @_Z1ml(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[L:%.*]] = alloca i8, align 1
@@ -20,7 +20,7 @@ define dso_local void @_Z1ml(i64 %e) {
 ; CHECK:       while.cond:
 ; CHECK-NEXT:    [[TMP1]] = phi ptr [ [[L]], [[ENTRY:%.*]] ], [ [[TMP0]], [[WHILE_COND_LOOPEXIT]] ]
 ; CHECK-NEXT:    [[I_0]] = phi ptr [ [[L]], [[ENTRY]] ], [ [[I_1_LCSSA]], [[WHILE_COND_LOOPEXIT]] ]
-; CHECK-NEXT:    br i1 undef, label [[FOR_BODY_LR_PH:%.*]], label [[WHILE_COND_LOOPEXIT]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_BODY_LR_PH:%.*]], label [[WHILE_COND_LOOPEXIT]]
 ; CHECK:       for.body.lr.ph:
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
 ; CHECK:       for.body:
@@ -32,7 +32,7 @@ define dso_local void @_Z1ml(i64 %e) {
 ; CHECK-NEXT:    store i8 [[TMP4]], ptr [[TMP2]], align 1
 ; CHECK-NEXT:    br label [[_Z1DPCS_L_EXIT:%.*]]
 ; CHECK:       _Z1dPcS_l.exit:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN3:%.*]], label [[IF_END5]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[IF_THEN3:%.*]], label [[IF_END5]]
 ; CHECK:       if.then3:
 ; CHECK-NEXT:    [[ADD_PTR4:%.*]] = getelementptr inbounds i8, ptr [[I_15]], i64 [[E]]
 ; CHECK-NEXT:    br label [[IF_END5]]
@@ -55,7 +55,7 @@ while.cond.loopexit:                              ; preds = %while.cond, %for.co
 while.cond:                                       ; preds = %while.cond.loopexit, %entry
   %1 = phi ptr [ %l, %entry ], [ %0, %while.cond.loopexit ]
   %i.0 = phi ptr [ %l, %entry ], [ %i.1.lcssa, %while.cond.loopexit ]
-  br i1 undef, label %for.body.lr.ph, label %while.cond.loopexit
+  br i1 %arg, label %for.body.lr.ph, label %while.cond.loopexit
 
 for.body.lr.ph:                                   ; preds = %while.cond
   br label %for.body
@@ -70,7 +70,7 @@ for.body:                                         ; preds = %if.end5, %for.body.
   br label %_Z1dPcS_l.exit
 
 _Z1dPcS_l.exit:                                   ; preds = %for.body
-  br i1 undef, label %if.then3, label %if.end5
+  br i1 %arg, label %if.then3, label %if.end5
 
 if.then3:                                         ; preds = %_Z1dPcS_l.exit
   %add.ptr4 = getelementptr inbounds i8, ptr %i.15, i64 %e

>From 60ee9814d04c18aca52caf7f0abff9ff560400fe Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Thu, 21 Nov 2024 20:49:07 -0700
Subject: [PATCH 2/7] Remove br i1 undef in MergedLoadStoreMotion directory

---
 .../MergedLoadStoreMotion/st_sink_debuginvariant.ll           | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/MergedLoadStoreMotion/st_sink_debuginvariant.ll b/llvm/test/Transforms/MergedLoadStoreMotion/st_sink_debuginvariant.ll
index a9373fab22ca77..86cf7117b6da10 100644
--- a/llvm/test/Transforms/MergedLoadStoreMotion/st_sink_debuginvariant.ll
+++ b/llvm/test/Transforms/MergedLoadStoreMotion/st_sink_debuginvariant.ll
@@ -18,9 +18,9 @@
 @g_173 = dso_local local_unnamed_addr global i16 0, !dbg !0
 
 ; Function Attrs: noinline norecurse nounwind
-define dso_local void @func_34(ptr noalias sret(%struct.S0) %agg.result) local_unnamed_addr #0 !dbg !11 {
+define dso_local void @func_34(ptr noalias sret(%struct.S0) %agg.result, i1 %arg) local_unnamed_addr #0 !dbg !11 {
 entry:
-  br i1 undef, label %if.end, label %if.then, !dbg !18
+  br i1 %arg, label %if.end, label %if.then, !dbg !18
 
 if.then:                                          ; preds = %entry
   call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22

>From bf16730ce3fb8ad0a3e0f869e8100f5fb305fa97 Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Thu, 21 Nov 2024 23:08:10 -0700
Subject: [PATCH 3/7] Remove br i1 undef in NewGVN directory

---
 .../NewGVN/2010-03-31-RedundantPHIs.ll        | 23 +++++----
 .../Transforms/NewGVN/2010-05-08-OneBit.ll    |  8 ++--
 .../NewGVN/2011-04-27-phioperands.ll          | 22 ++++-----
 .../Transforms/NewGVN/2012-05-22-PreCrash.ll  |  6 +--
 .../Transforms/NewGVN/basic-cyclic-opt.ll     | 20 ++++----
 llvm/test/Transforms/NewGVN/completeness.ll   | 18 +++----
 llvm/test/Transforms/NewGVN/crash.ll          | 24 +++++-----
 llvm/test/Transforms/NewGVN/deadstore.ll      |  6 +--
 .../Transforms/NewGVN/eliminate-ssacopy.ll    | 21 ++++----
 .../Transforms/NewGVN/metadata-nonnull.ll     | 40 ++++++++--------
 .../NewGVN/phi-of-ops-move-block.ll           |  6 +--
 .../phi-of-ops-simplification-dependencies.ll |  6 +--
 llvm/test/Transforms/NewGVN/pr25440.ll        | 48 ++++++++++---------
 llvm/test/Transforms/NewGVN/pr31594.ll        | 11 +++--
 llvm/test/Transforms/NewGVN/pr31613.ll        | 15 +++---
 llvm/test/Transforms/NewGVN/pr31682.ll        |  6 +--
 llvm/test/Transforms/NewGVN/pr32403.ll        | 19 ++++----
 llvm/test/Transforms/NewGVN/pr32838.ll        | 41 ++++++++--------
 llvm/test/Transforms/NewGVN/pr32845.ll        | 13 +++--
 llvm/test/Transforms/NewGVN/pr32897.ll        |  6 +--
 llvm/test/Transforms/NewGVN/pr32934.ll        |  8 ++--
 llvm/test/Transforms/NewGVN/pr33014.ll        | 12 ++---
 llvm/test/Transforms/NewGVN/pr33086.ll        |  8 ++--
 llvm/test/Transforms/NewGVN/pr33116.ll        | 10 ++--
 llvm/test/Transforms/NewGVN/pr33187.ll        | 30 ++++++------
 llvm/test/Transforms/NewGVN/pr33204.ll        | 10 ++--
 llvm/test/Transforms/NewGVN/pr33432.ll        |  6 +--
 llvm/test/Transforms/NewGVN/pr33720.ll        | 14 +++---
 llvm/test/Transforms/NewGVN/pr34430.ll        | 10 ++--
 llvm/test/Transforms/NewGVN/pr35074.ll        |  6 +--
 .../Transforms/NewGVN/pr42422-phi-of-ops.ll   | 30 +++++-------
 llvm/test/Transforms/NewGVN/pr43441.ll        | 16 ++++---
 .../Transforms/NewGVN/pre-new-inst-xfail.ll   |  4 +-
 llvm/test/Transforms/NewGVN/predicates.ll     |  9 ++--
 llvm/test/Transforms/NewGVN/refine-stores.ll  | 28 +++++------
 .../test/Transforms/NewGVN/stale-loop-info.ll |  7 +--
 .../NewGVN/unreachable_block_infinite_loop.ll |  8 ++--
 37 files changed, 290 insertions(+), 285 deletions(-)

diff --git a/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll b/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
index c6fc7b99cdf8df..14a16a05e74ae7 100644
--- a/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
+++ b/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
@@ -4,42 +4,45 @@
 ; CHECK-NOT: load
 ; CHECK-NOT: phi
 
-define ptr @cat(ptr %s1, ...) nounwind {
+define ptr @cat(ptr %s1, i1 %arg, ...) nounwind {
 ; CHECK-LABEL: define ptr @cat(
-; CHECK-SAME: ptr [[S1:%.*]], ...) #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: ptr [[S1:%.*]], i1 [[ARG:%.*]], ...) #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[BB:%.*]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 false, label [[BB:%.*]], label [[BB3:%.*]]
 ; CHECK:       bb:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb3:
 ; CHECK-NEXT:    store ptr undef, ptr undef, align 4
-; CHECK-NEXT:    br i1 undef, label [[BB5:%.*]], label [[BB6:%.*]]
+; CHECK-NEXT:    br i1 false, label [[BB5:%.*]], label [[BB6:%.*]]
 ; CHECK:       bb5:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb6:
 ; CHECK-NEXT:    br label [[BB12:%.*]]
 ; CHECK:       bb8:
-; CHECK-NEXT:    br i1 undef, label [[BB9:%.*]], label [[BB10:%.*]]
+; CHECK-NEXT:    br i1 true, label [[BB9:%.*]], label [[BB10:%.*]]
 ; CHECK:       bb9:
 ; CHECK-NEXT:    br label [[BB11:%.*]]
 ; CHECK:       bb10:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[BB11]]
 ; CHECK:       bb11:
 ; CHECK-NEXT:    br label [[BB12]]
 ; CHECK:       bb12:
-; CHECK-NEXT:    br i1 undef, label [[BB8:%.*]], label [[BB13:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB8:%.*]], label [[BB13:%.*]]
 ; CHECK:       bb13:
 ; CHECK-NEXT:    ret ptr undef
 ;
 entry:
-  br i1 undef, label %bb, label %bb3
+  br i1 false, label %bb, label %bb3
 
 bb:                                               ; preds = %entry
   unreachable
 
 bb3:                                              ; preds = %entry
   store ptr undef, ptr undef, align 4
-  br i1 undef, label %bb5, label %bb6
+  br i1 false, label %bb5, label %bb6
 
 bb5:                                              ; preds = %bb3
   unreachable
@@ -48,7 +51,7 @@ bb6:                                              ; preds = %bb3
   br label %bb12
 
 bb8:                                              ; preds = %bb12
-  br i1 undef, label %bb9, label %bb10
+  br i1 %arg, label %bb9, label %bb10
 
 bb9:                                              ; preds = %bb8
   %0 = load ptr, ptr undef, align 4                   ; <ptr> [#uses=0]
@@ -62,7 +65,7 @@ bb11:                                             ; preds = %bb10, %bb9
   br label %bb12
 
 bb12:                                             ; preds = %bb11, %bb6
-  br i1 undef, label %bb8, label %bb13
+  br i1 %arg, label %bb8, label %bb13
 
 bb13:                                             ; preds = %bb12
   ret ptr undef
diff --git a/llvm/test/Transforms/NewGVN/2010-05-08-OneBit.ll b/llvm/test/Transforms/NewGVN/2010-05-08-OneBit.ll
index 0a121ffab761f4..ebc89c5c5489aa 100644
--- a/llvm/test/Transforms/NewGVN/2010-05-08-OneBit.ll
+++ b/llvm/test/Transforms/NewGVN/2010-05-08-OneBit.ll
@@ -5,11 +5,11 @@
 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"
 target triple = "x86_64-unknown-linux-gnu"
 
-define i32 @main(i32 %argc, ptr nocapture %argv) personality ptr @__gxx_personality_v0 {
+define i32 @main(i32 %argc, ptr nocapture %argv, i1 %arg, i32 %arg2) personality ptr @__gxx_personality_v0 {
 entry:
   %0 = getelementptr inbounds i8, ptr undef, i64 5    ; <ptr> [#uses=1]
   store i32 undef, ptr %0, align 1
-  br i1 undef, label %k121.i.i, label %l117.i.i
+  br i1 %arg, label %k121.i.i, label %l117.i.i
 
 l117.i.i:                                         ; preds = %entry
   invoke fastcc void @foo()
@@ -19,7 +19,7 @@ l117.i.i:                                         ; preds = %entry
   unreachable
 
 k121.i.i:                                         ; preds = %entry
-  br i1 undef, label %l129.i.i, label %k133.i.i
+  br i1 %arg, label %l129.i.i, label %k133.i.i
 
 l129.i.i:                                         ; preds = %k121.i.i
   invoke fastcc void @foo()
@@ -46,7 +46,7 @@ k151.i.i:                                         ; preds = %k133.i.i
 landing_pad:                                      ; preds = %l147.i.i, %l129.i.i, %l117.i.i
   %exn = landingpad {ptr, i32}
   cleanup
-  switch i32 undef, label %fin [
+  switch i32 %arg2, label %fin [
   i32 1, label %catch1
   i32 2, label %catch
   ]
diff --git a/llvm/test/Transforms/NewGVN/2011-04-27-phioperands.ll b/llvm/test/Transforms/NewGVN/2011-04-27-phioperands.ll
index c039422be84ed1..31b674d03b5e27 100644
--- a/llvm/test/Transforms/NewGVN/2011-04-27-phioperands.ll
+++ b/llvm/test/Transforms/NewGVN/2011-04-27-phioperands.ll
@@ -5,12 +5,12 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
 
 @nuls = external global [10 x i8]
 
-define fastcc void @p_ere() nounwind {
+define fastcc void @p_ere(i1 %arg, i32 %arg2) nounwind {
 entry:
   br label %"<bb 5>"
 
 "<L18>.i":
-  br i1 undef, label %"<bb 3>.i30.i", label %doemit.exit51.i
+  br i1 %arg, label %"<bb 3>.i30.i", label %doemit.exit51.i
 
 "<bb 3>.i30.i":
   unreachable
@@ -19,7 +19,7 @@ doemit.exit51.i:
   br label %"<bb 53>.i"
 
 "<L19>.i":
-  br i1 undef, label %"<bb 3>.i55.i", label %doemit.exit76.i
+  br i1 %arg, label %"<bb 3>.i55.i", label %doemit.exit76.i
 
 "<bb 3>.i55.i":
   unreachable
@@ -35,7 +35,7 @@ doemit.exit76.i:
   br label %"<bb 53>.i"
 
 "<L24>.i":
-  br i1 undef, label %"<bb 53>.i", label %"<bb 35>.i"
+  br i1 %arg, label %"<bb 53>.i", label %"<bb 35>.i"
 
 "<bb 35>.i":
   br label %"<bb 53>.i"
@@ -52,19 +52,19 @@ doemit.exit76.i:
 "<bb 53>.i":
   %wascaret_2.i = phi i32 [ 0, %"<L39>.i" ], [ 0, %"<L29>.i" ], [ 0, %"<L28>.i" ], [ 0, %"<bb 35>.i" ], [ 0, %"<L99>.i" ], [ 0, %"<L98>.i" ], [ 0, %doemit.exit76.i ], [ 1, %doemit.exit51.i ], [ 0, %"<L24>.i" ]
   %D.5496_84.i = load ptr, ptr undef, align 8
-  br i1 undef, label %"<bb 54>.i", label %"<bb 5>"
+  br i1 %arg, label %"<bb 54>.i", label %"<bb 5>"
 
 "<bb 54>.i":
-  br i1 undef, label %"<bb 5>", label %"<bb 58>.i"
+  br i1 %arg, label %"<bb 5>", label %"<bb 58>.i"
 
 "<bb 58>.i":
-  br i1 undef, label %"<bb 64>.i", label %"<bb 59>.i"
+  br i1 %arg, label %"<bb 64>.i", label %"<bb 59>.i"
 
 "<bb 59>.i":
   br label %"<bb 64>.i"
 
 "<bb 64>.i":
-  switch i32 undef, label %"<bb 5>" [
+  switch i32 %arg2, label %"<bb 5>" [
   i32 42, label %"<L54>.i"
   i32 43, label %"<L55>.i"
   i32 63, label %"<L56>.i"
@@ -72,7 +72,7 @@ doemit.exit76.i:
   ]
 
 "<L54>.i":
-  br i1 undef, label %"<bb 3>.i105.i", label %doemit.exit127.i
+  br i1 %arg, label %"<bb 3>.i105.i", label %doemit.exit127.i
 
 "<bb 3>.i105.i":
   unreachable
@@ -81,7 +81,7 @@ doemit.exit127.i:
   unreachable
 
 "<L55>.i":
-  br i1 undef, label %"<bb 3>.i157.i", label %"<bb 5>"
+  br i1 %arg, label %"<bb 3>.i157.i", label %"<bb 5>"
 
 "<bb 3>.i157.i":
   unreachable
@@ -93,7 +93,7 @@ doemit.exit127.i:
   unreachable
 
 "<bb 5>":
-  switch i32 undef, label %"<L39>.i" [
+  switch i32 %arg2, label %"<L39>.i" [
   i32 36, label %"<L19>.i"
   i32 94, label %"<L18>.i"
   i32 124, label %"<L98>.i"
diff --git a/llvm/test/Transforms/NewGVN/2012-05-22-PreCrash.ll b/llvm/test/Transforms/NewGVN/2012-05-22-PreCrash.ll
index 1357f2b809f748..3e7e9bdf2ce7d7 100644
--- a/llvm/test/Transforms/NewGVN/2012-05-22-PreCrash.ll
+++ b/llvm/test/Transforms/NewGVN/2012-05-22-PreCrash.ll
@@ -2,9 +2,9 @@
 ; RUN: opt < %s -passes=newgvn
 ; PR12858
 
-define void @fn5(i16 signext %p1, i8 signext %p2) nounwind uwtable {
+define void @fn5(i16 signext %p1, i8 signext %p2, i1 %arg) nounwind uwtable {
 entry:
-  br i1 undef, label %if.else, label %if.then
+  br i1 %arg, label %if.else, label %if.then
 
 if.then:                                          ; preds = %entry
   br label %if.end
@@ -15,7 +15,7 @@ if.else:                                          ; preds = %entry
 
 if.end:                                           ; preds = %if.else, %if.then
   %conv1 = sext i16 %p1 to i32
-  br i1 undef, label %if.then3, label %if.else4
+  br i1 %arg, label %if.then3, label %if.else4
 
 if.then3:                                         ; preds = %if.end
   br label %if.end12
diff --git a/llvm/test/Transforms/NewGVN/basic-cyclic-opt.ll b/llvm/test/Transforms/NewGVN/basic-cyclic-opt.ll
index 53190466963a19..1cf9fd90095642 100644
--- a/llvm/test/Transforms/NewGVN/basic-cyclic-opt.ll
+++ b/llvm/test/Transforms/NewGVN/basic-cyclic-opt.ll
@@ -242,21 +242,21 @@ bb23:                                             ; preds = %bb4
 ;; Both loads should equal 0, but it requires being
 ;; completely optimistic about MemoryPhis, otherwise
 ;; we will not be able to see through the cycle.
-define i8 @irreducible_memoryphi(ptr noalias %arg, ptr noalias %arg2) {
+define i8 @irreducible_memoryphi(ptr noalias %arg, ptr noalias %arg2, i1 %arg3) {
 ; CHECK-LABEL: @irreducible_memoryphi(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    store i8 0, ptr [[ARG:%.*]], align 1
-; CHECK-NEXT:    br i1 undef, label [[BB2:%.*]], label [[BB1:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3:%.*]], label [[BB2:%.*]], label [[BB1:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    br label [[BB2]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    br i1 undef, label [[BB1]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3]], label [[BB1]], label [[BB3:%.*]]
 ; CHECK:       bb3:
 ; CHECK-NEXT:    ret i8 0
 ;
 bb:
   store i8 0, ptr %arg
-  br i1 undef, label %bb2, label %bb1
+  br i1 %arg3, label %bb2, label %bb1
 
 bb1:                                              ; preds = %bb2, %bb
   br label %bb2
@@ -264,7 +264,7 @@ bb1:                                              ; preds = %bb2, %bb
 bb2:                                              ; preds = %bb1, %bb
   %tmp2 = load i8, ptr %arg
   store i8 0, ptr %arg
-  br i1 undef, label %bb1, label %bb3
+  br i1 %arg3, label %bb1, label %bb3
 
 bb3:                                              ; preds = %bb2
   %tmp = load i8, ptr %arg
@@ -277,20 +277,20 @@ bb3:                                              ; preds = %bb2
 ;; It should return 0, but it requires being
 ;; completely optimistic about phis, otherwise
 ;; we will not be able to see through the cycle.
-define i32 @irreducible_phi(i32 %arg) {
+define i32 @irreducible_phi(i32 %arg, i1 %arg2) {
 ; CHECK-LABEL: @irreducible_phi(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:    br i1 undef, label [[BB2:%.*]], label [[BB1:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[BB2:%.*]], label [[BB1:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    br label [[BB2]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    br i1 undef, label [[BB1]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[BB1]], label [[BB3:%.*]]
 ; CHECK:       bb3:
 ; CHECK-NEXT:    ret i32 0
 ;
 bb:
   %tmp = add i32 0, %arg
-  br i1 undef, label %bb2, label %bb1
+  br i1 %arg2, label %bb2, label %bb1
 
 bb1:                                              ; preds = %bb2, %bb
   %phi1 = phi i32 [%tmp, %bb], [%phi2, %bb2]
@@ -298,7 +298,7 @@ bb1:                                              ; preds = %bb2, %bb
 
 bb2:                                              ; preds = %bb1, %bb
   %phi2 = phi i32 [%tmp, %bb], [%phi1, %bb1]
-  br i1 undef, label %bb1, label %bb3
+  br i1 %arg2, label %bb1, label %bb3
 
 bb3:                                              ; preds = %bb2
   ; This should be zero
diff --git a/llvm/test/Transforms/NewGVN/completeness.ll b/llvm/test/Transforms/NewGVN/completeness.ll
index 17592ffaf5d432..5585d2bf1e678f 100644
--- a/llvm/test/Transforms/NewGVN/completeness.ll
+++ b/llvm/test/Transforms/NewGVN/completeness.ll
@@ -386,12 +386,12 @@ bb1:                                              ; preds = %bb1, %bb
 
 ;; Make sure we handle the case where we later come up with an expression that we need
 ;; for a phi of ops.
-define void @test9() {
+define void @test9(i1 %arg) {
 ; CHECK-LABEL: @test9(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
 ; CHECK:       bb1:
-; CHECK-NEXT:    br i1 undef, label [[BB1]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[BB1]], label [[BB2:%.*]]
 ; CHECK:       bb2:
 ; CHECK-NEXT:    br label [[BB6:%.*]]
 ; CHECK:       bb6:
@@ -405,7 +405,7 @@ bb:
   br label %bb1
 
 bb1:                                              ; preds = %bb1, %bb
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb2:                                              ; preds = %bb1
   %tmp = select i1 true, i32 -14, i32 -10
@@ -426,7 +426,7 @@ bb6:                                              ; preds = %bb6, %bb2
 }
 
 ;; Ensure that we revisit predicateinfo operands at the right points in time.
-define void @test10() {
+define void @test10(i1 %arg) {
 ; CHECK-LABEL: @test10(
 ; CHECK-NEXT:  b:
 ; CHECK-NEXT:    br label [[G:%.*]]
@@ -436,7 +436,7 @@ define void @test10() {
 ; CHECK-NEXT:    [[J:%.*]] = icmp eq ptr [[H]], inttoptr (i64 32 to ptr)
 ; CHECK-NEXT:    br i1 [[J]], label [[C:%.*]], label [[I]]
 ; CHECK:       i:
-; CHECK-NEXT:    br i1 undef, label [[K:%.*]], label [[G]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[K:%.*]], label [[G]]
 ; CHECK:       k:
 ; CHECK-NEXT:    br i1 false, label [[C]], label [[O:%.*]]
 ; CHECK:       o:
@@ -455,7 +455,7 @@ g:                                                ; preds = %i, %b
   br i1 %j, label %c, label %i
 
 i:                                                ; preds = %g
-  br i1 undef, label %k, label %g
+  br i1 %arg, label %k, label %g
 
 k:                                                ; preds = %i
   %l = icmp eq ptr %n, %m
@@ -470,10 +470,10 @@ c:                                                ; preds = %o, %k, %g
 }
 
 ;; Ensure we handle VariableExpression properly.
-define void @test11() {
+define void @test11(i1 %arg) {
 ; CHECK-LABEL: @test11(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    br label [[BB2]]
 ; CHECK:       bb2:
@@ -488,7 +488,7 @@ define void @test11() {
 ; CHECK-NEXT:    ret void
 ;
 bb:
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:                                              ; preds = %bb
   br label %bb2
diff --git a/llvm/test/Transforms/NewGVN/crash.ll b/llvm/test/Transforms/NewGVN/crash.ll
index 26eaa766a05434..02edc2ff8da7e2 100644
--- a/llvm/test/Transforms/NewGVN/crash.ll
+++ b/llvm/test/Transforms/NewGVN/crash.ll
@@ -6,9 +6,9 @@
 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"
 target triple = "x86_64-apple-darwin10.0"
 
-define ptr @test1(ptr %name, i32 %namelen, ptr %o, i32 %expected_type) nounwind ssp {
+define ptr @test1(ptr %name, i32 %namelen, ptr %o, i32 %expected_type, i1 %arg) nounwind ssp {
 entry:
-  br i1 undef, label %if.end13, label %while.body.preheader
+  br i1 %arg, label %if.end13, label %while.body.preheader
 
 
 if.end13:                                         ; preds = %if.then6
@@ -23,25 +23,25 @@ while.body:                                       ; preds = %while.body.backedge
 
 lor.lhs.false:                                    ; preds = %while.body
   %tmp22 = load i32, ptr %o.addr.0                       ; <i32> [#uses=0]
-  br i1 undef, label %land.lhs.true24, label %if.end31
+  br i1 %arg, label %land.lhs.true24, label %if.end31
 
 land.lhs.true24:                                  ; preds = %lor.lhs.false
   %call28 = call ptr @parse_object(ptr undef) nounwind ; <ptr> [#uses=0]
-  br i1 undef, label %return.loopexit, label %if.end31
+  br i1 %arg, label %return.loopexit, label %if.end31
 
 if.end31:                                         ; preds = %land.lhs.true24, %lor.lhs.false
-  br i1 undef, label %return.loopexit, label %if.end41
+  br i1 %arg, label %return.loopexit, label %if.end41
 
 if.end41:                                         ; preds = %if.end31
   %tmp45 = load i32, ptr %o.addr.0                       ; <i32> [#uses=0]
-  br i1 undef, label %if.then50, label %if.else
+  br i1 %arg, label %if.then50, label %if.else
 
 if.then50:                                        ; preds = %if.end41
   %tmp53 = load ptr, ptr undef                       ; <ptr> [#uses=1]
   br label %while.body.backedge
 
 if.else:                                          ; preds = %if.end41
-  br i1 undef, label %if.then62, label %if.else67
+  br i1 %arg, label %if.then62, label %if.else67
 
 if.then62:                                        ; preds = %if.else
   br label %while.body.backedge
@@ -98,10 +98,10 @@ bb66.i:                                           ; Unreachable
 
 @g = external global i64, align 8
 
-define ptr @test3() {
+define ptr @test3(i1 %arg) {
 do.end17.i:
   %tmp18.i = load ptr, ptr undef
-  br i1 undef, label %do.body36.i, label %if.then21.i
+  br i1 %arg, label %do.body36.i, label %if.then21.i
 
 if.then21.i:
   ret ptr undef
@@ -111,7 +111,7 @@ do.body36.i:
   %add.ptr39.sum.i = add i64 %ivar38.i, 8
   %tmp40.i = getelementptr inbounds i8, ptr %tmp18.i, i64 %add.ptr39.sum.i
   %tmp41.i = load i64, ptr %tmp40.i
-  br i1 undef, label %if.then48.i, label %do.body57.i
+  br i1 %arg, label %if.then48.i, label %do.body57.i
 
 if.then48.i:
   %call54.i = call i32 @foo2()
@@ -164,7 +164,7 @@ entry:
 
 %struct.type = type { i64, i32, i32 }
 
-define fastcc void @func() nounwind uwtable ssp align 2 {
+define fastcc void @func(i1 %arg) nounwind uwtable ssp align 2 {
 entry:
   br label %reachable.bb
 
@@ -172,7 +172,7 @@ entry:
 
 unreachable.bb:
   %gep.val = getelementptr inbounds %struct.type, ptr %gep.val, i64 1
-  br i1 undef, label %u2.bb, label %u1.bb
+  br i1 %arg, label %u2.bb, label %u1.bb
 
 u1.bb:
   store i64 -1, ptr %gep.val, align 8
diff --git a/llvm/test/Transforms/NewGVN/deadstore.ll b/llvm/test/Transforms/NewGVN/deadstore.ll
index ef8bdf38b658fb..61597411e7c107 100644
--- a/llvm/test/Transforms/NewGVN/deadstore.ll
+++ b/llvm/test/Transforms/NewGVN/deadstore.ll
@@ -50,7 +50,7 @@ bb3:
 
 declare void @unknown_func()
 ; Remove redundant store, which is in the same loop as the load.
-define i32 @test33(i1 %c, ptr %p, i32 %i) {
+define i32 @test33(i1 %c, ptr %p, i32 %i, i1 %arg) {
 ; CHECK-LABEL: @test33(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
@@ -59,7 +59,7 @@ define i32 @test33(i1 %c, ptr %p, i32 %i) {
 ; CHECK-NEXT:    br label [[BB2:%.*]]
 ; CHECK:       bb2:
 ; CHECK-NEXT:    call void @unknown_func()
-; CHECK-NEXT:    br i1 undef, label [[BB1]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[BB1]], label [[BB3:%.*]]
 ; CHECK:       bb3:
 ; CHECK-NEXT:    ret i32 0
 ;
@@ -72,7 +72,7 @@ bb2:
   store i32 %v, ptr %p, align 4
   ; Might read and overwrite value at %p, but doesn't matter.
   call void @unknown_func()
-  br i1 undef, label %bb1, label %bb3
+  br i1 %arg, label %bb1, label %bb3
 bb3:
   ret i32 0
 }
diff --git a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
index 9dc83b747ca480..dd65861076c526 100644
--- a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
+++ b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
@@ -12,37 +12,34 @@
 define void @g() {
 ; CHECK-LABEL: @g(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 true, label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
 ; CHECK:       for.cond.preheader:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       for.cond1thread-pre-split:
 ; CHECK-NEXT:    br label [[FOR_END4_SPLIT:%.*]]
 ; CHECK:       for.end4.split:
 ; CHECK-NEXT:    br i1 true, label [[FOR_COND6_PREHEADER:%.*]], label [[IF_END11:%.*]]
 ; CHECK:       for.cond6.preheader:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND6_PREHEADER3:%.*]], label [[IF_END11_LOOPEXIT:%.*]]
+; CHECK-NEXT:    br i1 true, label [[FOR_COND6_PREHEADER3:%.*]], label [[IF_END11_LOOPEXIT:%.*]]
 ; CHECK:       for.cond6.preheader3:
 ; CHECK-NEXT:    br label [[IF_END11_LOOPEXIT]]
 ; CHECK:       if.end11.loopexit:
-; CHECK-NEXT:    [[STOREMERGE_LCSSA:%.*]] = phi i32 [ 0, [[FOR_COND6_PREHEADER]] ], [ 1, [[FOR_COND6_PREHEADER3]] ]
-; CHECK-NEXT:    store i32 [[STOREMERGE_LCSSA]], ptr @b, align 4
+; CHECK-NEXT:    store i32 1, ptr @b, align 4
 ; CHECK-NEXT:    br label [[IF_END11]]
 ; CHECK:       if.end11:
-; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @b, align 4
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr @a, align 1
 ; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[TMP1]] to i32
-; CHECK-NEXT:    [[CMP12:%.*]] = icmp eq i32 [[TMP0]], [[CONV]]
+; CHECK-NEXT:    [[CMP12:%.*]] = icmp eq i32 1, [[CONV]]
 ; CHECK-NEXT:    br i1 [[CMP12]], label [[IF_THEN14:%.*]], label [[IF_END16:%.*]]
 ; CHECK:       if.then14:
-; CHECK-NEXT:    [[CONV15:%.*]] = trunc i32 [[TMP0]] to i16
-; CHECK-NEXT:    store i16 [[CONV15]], ptr @f, align 2
+; CHECK-NEXT:    store i16 1, ptr @f, align 2
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end16:
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  %tobool = icmp eq i32 undef, 0
-  br i1 %tobool, label %for.cond1thread-pre-split, label %for.cond.preheader
+  br i1 true, label %for.cond1thread-pre-split, label %for.cond.preheader
 
 for.cond.preheader:                               ; preds = %entry
   unreachable
@@ -51,10 +48,10 @@ for.cond1thread-pre-split:                        ; preds = %entry
   br label %for.end4.split
 
 for.end4.split:                                   ; preds = %for.cond1thread-pre-split
-  br i1 %tobool, label %for.cond6.preheader, label %if.end11
+  br i1 true, label %for.cond6.preheader, label %if.end11
 
 for.cond6.preheader:                              ; preds = %for.end4.split
-  br i1 undef, label %for.cond6.preheader3, label %if.end11.loopexit
+  br i1 true, label %for.cond6.preheader3, label %if.end11.loopexit
 
 for.cond6.preheader3:                             ; preds = %for.cond6.preheader
   br label %if.end11.loopexit
diff --git a/llvm/test/Transforms/NewGVN/metadata-nonnull.ll b/llvm/test/Transforms/NewGVN/metadata-nonnull.ll
index 5de4c581c051c3..861fc9d0186b1c 100644
--- a/llvm/test/Transforms/NewGVN/metadata-nonnull.ll
+++ b/llvm/test/Transforms/NewGVN/metadata-nonnull.ll
@@ -36,13 +36,13 @@ top:
 
 declare void @use1(ptr %a) readonly
 
-define ptr @test3(ptr %v0) {
+define ptr @test3(ptr %v0, i1 %arg) {
 ; CHECK-LABEL: define ptr @test3
-; CHECK-SAME: (ptr [[V0:%.*]]) {
+; CHECK-SAME: (ptr [[V0:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  top:
 ; CHECK-NEXT:    [[V1:%.*]] = load ptr, ptr [[V0]], align 8
 ; CHECK-NEXT:    call void @use1(ptr [[V1]])
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    ret ptr [[V1]]
 ; CHECK:       bb2:
@@ -51,7 +51,7 @@ define ptr @test3(ptr %v0) {
 top:
   %v1 = load ptr, ptr %v0
   call void @use1(ptr %v1)
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:
   %v2 = load ptr, ptr %v0, !nonnull !0
@@ -62,13 +62,13 @@ bb2:
   ret ptr %v3
 }
 
-define ptr @test4(ptr %v0) {
+define ptr @test4(ptr %v0, i1 %arg) {
 ; CHECK-LABEL: define ptr @test4
-; CHECK-SAME: (ptr [[V0:%.*]]) {
+; CHECK-SAME: (ptr [[V0:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  top:
 ; CHECK-NEXT:    [[V1:%.*]] = load ptr, ptr [[V0]], align 8
 ; CHECK-NEXT:    call void @use1(ptr [[V1]])
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    ret ptr [[V1]]
 ; CHECK:       bb2:
@@ -77,7 +77,7 @@ define ptr @test4(ptr %v0) {
 top:
   %v1 = load ptr, ptr %v0
   call void @use1(ptr %v1)
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:
   %v2 = load ptr, ptr %v0
@@ -88,13 +88,13 @@ bb2:
   ret ptr %v3
 }
 
-define ptr @test5(ptr %v0) {
+define ptr @test5(ptr %v0, i1 %arg) {
 ; CHECK-LABEL: define ptr @test5
-; CHECK-SAME: (ptr [[V0:%.*]]) {
+; CHECK-SAME: (ptr [[V0:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  top:
 ; CHECK-NEXT:    [[V1:%.*]] = load ptr, ptr [[V0]], align 8
 ; CHECK-NEXT:    call void @use1(ptr [[V1]])
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    ret ptr [[V1]]
 ; CHECK:       bb2:
@@ -103,7 +103,7 @@ define ptr @test5(ptr %v0) {
 top:
   %v1 = load ptr, ptr %v0, !nonnull !0
   call void @use1(ptr %v1)
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:
   %v2 = load ptr, ptr %v0
@@ -114,11 +114,11 @@ bb2:
   ret ptr %v3
 }
 
-define ptr @test6(ptr %v0, ptr %v1) {
+define ptr @test6(ptr %v0, ptr %v1, i1 %arg) {
 ; CHECK-LABEL: define ptr @test6
-; CHECK-SAME: (ptr [[V0:%.*]], ptr [[V1:%.*]]) {
+; CHECK-SAME: (ptr [[V0:%.*]], ptr [[V1:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  top:
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    [[V2:%.*]] = load ptr, ptr [[V0]], align 8
 ; CHECK-NEXT:    store ptr [[V2]], ptr [[V1]], align 8
@@ -129,7 +129,7 @@ define ptr @test6(ptr %v0, ptr %v1) {
 ; CHECK-NEXT:    ret ptr [[V4]]
 ;
 top:
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:
   %v2 = load ptr, ptr %v0, !nonnull !0
@@ -146,13 +146,13 @@ bb2:
 
 declare void @use2(ptr %a)
 
-define ptr @test7(ptr %v0) {
+define ptr @test7(ptr %v0, i1 %arg) {
 ; CHECK-LABEL: define ptr @test7
-; CHECK-SAME: (ptr [[V0:%.*]]) {
+; CHECK-SAME: (ptr [[V0:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  top:
 ; CHECK-NEXT:    [[V1:%.*]] = load ptr, ptr [[V0]], align 8, !nonnull [[META0:![0-9]+]]
 ; CHECK-NEXT:    call void @use2(ptr [[V1]])
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    [[V2:%.*]] = load ptr, ptr [[V0]], align 8
 ; CHECK-NEXT:    ret ptr [[V2]]
@@ -163,7 +163,7 @@ define ptr @test7(ptr %v0) {
 top:
   %v1 = load ptr, ptr %v0, !nonnull !0
   call void @use2(ptr %v1)
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg, label %bb1, label %bb2
 
 bb1:
   %v2 = load ptr, ptr %v0
diff --git a/llvm/test/Transforms/NewGVN/phi-of-ops-move-block.ll b/llvm/test/Transforms/NewGVN/phi-of-ops-move-block.ll
index db6693dd7ab7ea..fcd2b6bb989b4d 100644
--- a/llvm/test/Transforms/NewGVN/phi-of-ops-move-block.ll
+++ b/llvm/test/Transforms/NewGVN/phi-of-ops-move-block.ll
@@ -57,7 +57,7 @@ end:
 
 ; In this test case a temporary PhiOfOps node gets moved to BB with more
 ; predecessors, so a new one needs to be created.
-define void @test2() {
+define void @test2(i1 %arg) {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    br label [[BB1:%.*]]
 ; CHECK:       bb1:
@@ -65,7 +65,7 @@ define void @test2() {
 ; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i32 [[STOREMERGE]], 0
 ; CHECK-NEXT:    br i1 [[CMP1]], label [[LR_PH:%.*]], label [[CRITEDGE]]
 ; CHECK:       lr.ph:
-; CHECK-NEXT:    br i1 undef, label [[SPLIT1:%.*]], label [[SPLIT2:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[SPLIT1:%.*]], label [[SPLIT2:%.*]]
 ; CHECK:       split1:
 ; CHECK-NEXT:    br label [[CRITEDGE]]
 ; CHECK:       split2:
@@ -87,7 +87,7 @@ bb1:                                      ; preds = %critedge, %0
   br i1 %cmp1, label %lr.ph, label %critedge
 
 lr.ph:                                           ; preds = %bb1
-  br i1 undef, label %split1, label %split2
+  br i1 %arg, label %split1, label %split2
 
 split1:                                     ; preds = %lr.ph
   br label %critedge
diff --git a/llvm/test/Transforms/NewGVN/phi-of-ops-simplification-dependencies.ll b/llvm/test/Transforms/NewGVN/phi-of-ops-simplification-dependencies.ll
index f2df0d8c5e5c54..e47cd7a2d3b541 100644
--- a/llvm/test/Transforms/NewGVN/phi-of-ops-simplification-dependencies.ll
+++ b/llvm/test/Transforms/NewGVN/phi-of-ops-simplification-dependencies.ll
@@ -7,14 +7,14 @@ declare void @use.i32(i32)
 ; Test cases from PR35074, where the simplification dependencies need to be
 ; tracked for phi-of-ops root instructions.
 
-define void @test1() {
+define void @test1(i1 %arg) {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[FOR_COND:%.*]]
 ; CHECK:       for.cond:
 ; CHECK-NEXT:    [[PHIOFOPS:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[Y_0:%.*]], [[FOR_INC6:%.*]] ]
 ; CHECK-NEXT:    [[Y_0]] = phi i32 [ 1, [[ENTRY]] ], [ [[INC7:%.*]], [[FOR_INC6]] ]
-; CHECK-NEXT:    br i1 undef, label [[FOR_INC6]], label [[FOR_BODY_LR_PH:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[FOR_INC6]], label [[FOR_BODY_LR_PH:%.*]]
 ; CHECK:       for.body.lr.ph:
 ; CHECK-NEXT:    br label [[FOR_BODY4:%.*]]
 ; CHECK:       for.body4:
@@ -35,7 +35,7 @@ entry:
 
 for.cond:                                         ; preds = %for.inc6, %entry
   %y.0 = phi i32 [ 1, %entry ], [ %inc7, %for.inc6 ]
-  br i1 undef, label %for.inc6, label %for.body.lr.ph
+  br i1 %arg, label %for.inc6, label %for.body.lr.ph
 
 for.body.lr.ph:                                   ; preds = %for.cond
   %sub = add nsw i32 %y.0, -1
diff --git a/llvm/test/Transforms/NewGVN/pr25440.ll b/llvm/test/Transforms/NewGVN/pr25440.ll
index 9d9c4cda342581..fe87d134ec3d54 100644
--- a/llvm/test/Transforms/NewGVN/pr25440.ll
+++ b/llvm/test/Transforms/NewGVN/pr25440.ll
@@ -10,38 +10,39 @@ target triple = "thumbv7--linux-gnueabi"
 @length = external global [0 x i32], align 4
 
 ; Function Attrs: nounwind
-define fastcc void @foo(ptr nocapture readonly %x) {
+define fastcc void @foo(ptr nocapture readonly %x, i1 %arg) {
 ; CHECK-LABEL: define fastcc void @foo(
-; CHECK-SAME: ptr nocapture readonly [[X:%.*]]) {
+; CHECK-SAME: ptr nocapture readonly [[X:%.*]], i1 [[ARG:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[BB0:%.*]]
 ; CHECK:       bb0:
-; CHECK-NEXT:    [[X_TR:%.*]] = phi ptr [ [[X]], [[ENTRY:%.*]] ], [ null, [[LAND_LHS_TRUE:%.*]] ]
-; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[X_TR]], align 4
+; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[X]], align 4
 ; CHECK-NEXT:    [[CONV:%.*]] = zext i16 [[TMP0]] to i32
 ; CHECK-NEXT:    switch i32 [[CONV]], label [[IF_END_50:%.*]] [
 ; CHECK-NEXT:      i32 43, label [[CLEANUP:%.*]]
 ; CHECK-NEXT:      i32 52, label [[IF_THEN_5:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       if.then.5:
-; CHECK-NEXT:    br i1 undef, label [[LAND_LHS_TRUE]], label [[IF_THEN_26:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[LAND_LHS_TRUE:%.*]], label [[IF_THEN_26:%.*]]
 ; CHECK:       land.lhs.true:
-; CHECK-NEXT:    br i1 undef, label [[CLEANUP]], label [[BB0]]
+; CHECK-NEXT:    br i1 true, label [[CLEANUP]], label [[BB0]]
 ; CHECK:       if.then.26:
-; CHECK-NEXT:    br i1 undef, label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK-NEXT:    br i1 false, label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
 ; CHECK:       cond.false:
-; CHECK-NEXT:    [[MODE:%.*]] = getelementptr inbounds [[STRUCT_A:%.*]], ptr [[X_TR]], i32 0, i32 1
+; CHECK-NEXT:    [[MODE:%.*]] = getelementptr inbounds [[STRUCT_A:%.*]], ptr [[X]], i32 0, i32 1
 ; CHECK-NEXT:    [[BF_LOAD:%.*]] = load i16, ptr [[MODE]], align 2
 ; CHECK-NEXT:    br label [[COND_END]]
 ; CHECK:       cond.end:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN_44:%.*]], label [[CLEANUP]]
+; CHECK-NEXT:    br i1 false, label [[IF_THEN_44:%.*]], label [[CLEANUP]]
 ; CHECK:       if.then.44:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end.50:
 ; CHECK-NEXT:    [[ARRAYIDX52:%.*]] = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 [[CONV]]
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX52]], align 4
-; CHECK-NEXT:    br i1 undef, label [[FOR_BODY_57:%.*]], label [[CLEANUP]]
+; CHECK-NEXT:    br i1 false, label [[FOR_BODY_57:%.*]], label [[CLEANUP]]
 ; CHECK:       for.body.57:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       cleanup:
 ; CHECK-NEXT:    ret void
@@ -59,14 +60,14 @@ bb0:                                      ; preds = %land.lhs.true, %entry
   ]
 
 if.then.5:                                        ; preds = %bb0
-  br i1 undef, label %land.lhs.true, label %if.then.26
+  br i1 %arg, label %land.lhs.true, label %if.then.26
 
 land.lhs.true:                                    ; preds = %if.then.5
-  br i1 undef, label %cleanup, label %bb0
+  br i1 true, label %cleanup, label %bb0
 
 if.then.26:                                       ; preds = %if.then.5
   %x.tr.lcssa163 = phi ptr [ %x.tr, %if.then.5 ]
-  br i1 undef, label %cond.end, label %cond.false
+  br i1 %arg, label %cond.end, label %cond.false
 
 cond.false:                                       ; preds = %if.then.26
   %mode = getelementptr inbounds %struct.a, ptr %x.tr.lcssa163, i32 0, i32 1
@@ -75,7 +76,7 @@ cond.false:                                       ; preds = %if.then.26
   br label %cond.end
 
 cond.end:                                         ; preds = %cond.false, %if.then.26
-  br i1 undef, label %if.then.44, label %cleanup
+  br i1 false, label %if.then.44, label %cleanup
 
 if.then.44:                                       ; preds = %cond.end
   unreachable
@@ -84,7 +85,7 @@ if.end.50:                                        ; preds = %bb0
   %conv.lcssa = phi i32 [ %conv, %bb0 ]
   %arrayidx52 = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 %conv.lcssa
   %1 = load i32, ptr %arrayidx52, align 4
-  br i1 undef, label %for.body.57, label %cleanup
+  br i1 false, label %for.body.57, label %cleanup
 
 for.body.57:                                      ; preds = %if.end.50
   %i.2157 = add nsw i32 %1, -1
@@ -97,12 +98,13 @@ cleanup:                                          ; preds = %if.end.50, %cond.en
 @yy_c_buf_p = external unnamed_addr global ptr, align 4
 @dfg_text = external global ptr, align 4
 
-define void @dfg_lex() {
-; CHECK-LABEL: define void @dfg_lex() {
+define void @dfg_lex(i1 %arg, i32 %arg2) {
+; CHECK-LABEL: define void @dfg_lex(
+; CHECK-SAME: i1 [[ARG:%.*]], i32 [[ARG2:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[WHILE_BODYTHREAD_PRE_SPLIT:%.*]]
 ; CHECK:       while.bodythread-pre-split:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN_14:%.*]], label [[IF_END_15:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[IF_THEN_14:%.*]], label [[IF_END_15:%.*]]
 ; CHECK:       if.then.14:
 ; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr @dfg_text, align 4
 ; CHECK-NEXT:    br label [[IF_END_15]]
@@ -110,12 +112,12 @@ define void @dfg_lex() {
 ; CHECK-NEXT:    [[V2:%.*]] = load ptr, ptr @yy_c_buf_p, align 4
 ; CHECK-NEXT:    br label [[WHILE_COND_16:%.*]]
 ; CHECK:       while.cond.16:
-; CHECK-NEXT:    br i1 undef, label [[WHILE_COND_16]], label [[WHILE_END:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[WHILE_COND_16]], label [[WHILE_END:%.*]]
 ; CHECK:       while.end:
 ; CHECK-NEXT:    [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[V2]], i32 undef
 ; CHECK-NEXT:    store ptr [[ADD_PTR]], ptr @dfg_text, align 4
 ; CHECK-NEXT:    [[SUB_PTR_RHS_CAST25:%.*]] = ptrtoint ptr [[ADD_PTR]] to i32
-; CHECK-NEXT:    switch i32 undef, label [[SW_DEFAULT:%.*]] [
+; CHECK-NEXT:    switch i32 [[ARG2]], label [[SW_DEFAULT:%.*]] [
 ; CHECK-NEXT:      i32 65, label [[WHILE_BODYTHREAD_PRE_SPLIT]]
 ; CHECK-NEXT:      i32 3, label [[RETURN:%.*]]
 ; CHECK-NEXT:      i32 57, label [[WHILE_BODYTHREAD_PRE_SPLIT]]
@@ -130,7 +132,7 @@ entry:
   br label %while.bodythread-pre-split
 
 while.bodythread-pre-split:                       ; preds = %while.end, %while.end, %entry
-  br i1 undef, label %if.then.14, label %if.end.15
+  br i1 %arg, label %if.then.14, label %if.end.15
 
 if.then.14:                                       ; preds = %while.end, %while.bodythread-pre-split
   %v1 = load i32, ptr @dfg_text, align 4
@@ -142,14 +144,14 @@ if.end.15:                                        ; preds = %if.then.14, %while.
   br label %while.cond.16
 
 while.cond.16:                                    ; preds = %while.cond.16, %if.end.15
-  br i1 undef, label %while.cond.16, label %while.end
+  br i1 %arg, label %while.cond.16, label %while.end
 
 while.end:                                        ; preds = %while.cond.16
   %add.ptr = getelementptr inbounds i8, ptr %v2, i32 undef
   store ptr %add.ptr, ptr @dfg_text, align 4
   %sub.ptr.rhs.cast25 = ptrtoint ptr %add.ptr to i32
   %sub.ptr.sub26 = sub i32 0, %sub.ptr.rhs.cast25
-  switch i32 undef, label %sw.default [
+  switch i32 %arg2, label %sw.default [
   i32 65, label %while.bodythread-pre-split
   i32 3, label %return
   i32 57, label %while.bodythread-pre-split
diff --git a/llvm/test/Transforms/NewGVN/pr31594.ll b/llvm/test/Transforms/NewGVN/pr31594.ll
index d1a02d62934dee..777bfbd6067f12 100644
--- a/llvm/test/Transforms/NewGVN/pr31594.ll
+++ b/llvm/test/Transforms/NewGVN/pr31594.ll
@@ -56,13 +56,13 @@ while.end:
 
 ;; This is an example of a case where the memory states are equivalent solely due to unreachability,
 ;; but the stores are not equal.
-define void @foo(ptr %arg) {
+define void @foo(ptr %arg, i1 %arg2) {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB2:%.*]] ]
-; CHECK-NEXT:    br i1 undef, label [[BB3:%.*]], label [[BB2]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[BB3:%.*]], label [[BB2]]
 ; CHECK:       bb2:
 ; CHECK-NEXT:    br label [[BB1]]
 ; CHECK:       bb3:
@@ -71,8 +71,9 @@ define void @foo(ptr %arg) {
 ; CHECK:       bb4:
 ; CHECK-NEXT:    br label [[BB6:%.*]]
 ; CHECK:       bb6:
-; CHECK-NEXT:    br i1 undef, label [[BB9:%.*]], label [[BB7:%.*]]
+; CHECK-NEXT:    br i1 true, label [[BB9:%.*]], label [[BB7:%.*]]
 ; CHECK:       bb7:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    switch i8 0, label [[BB6]] [
 ; CHECK-NEXT:      i8 6, label [[BB8:%.*]]
 ; CHECK-NEXT:    ]
@@ -88,7 +89,7 @@ bb:
 
 bb1:                                              ; preds = %bb2, %bb
   %tmp = phi ptr [ %arg, %bb ], [ null, %bb2 ]
-  br i1 undef, label %bb3, label %bb2
+  br i1 %arg2, label %bb3, label %bb2
 
 bb2:                                              ; preds = %bb1
   br label %bb1
@@ -102,7 +103,7 @@ bb4:                                              ; preds = %bb8, %bb3
   br label %bb6
 
 bb6:                                              ; preds = %bb7, %bb4
-  br i1 undef, label %bb9, label %bb7
+  br i1 %arg2, label %bb9, label %bb7
 
 bb7:                                              ; preds = %bb6
   switch i8 0, label %bb6 [
diff --git a/llvm/test/Transforms/NewGVN/pr31613.ll b/llvm/test/Transforms/NewGVN/pr31613.ll
index 0bcf86a5711189..2db3024a0b3bd1 100644
--- a/llvm/test/Transforms/NewGVN/pr31613.ll
+++ b/llvm/test/Transforms/NewGVN/pr31613.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 ;; Both of these tests are tests of phi nodes that end up all equivalent to each other
 ;; Without proper leader ordering, we will end up cycling the leader between all of them and never converge.
 
-define void @foo() {
+define void @foo(i1 %arg) {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
@@ -15,16 +15,17 @@ define void @foo() {
 ; CHECK:       bb2:
 ; CHECK-NEXT:    br label [[BB4:%.*]]
 ; CHECK:       bb4:
-; CHECK-NEXT:    br i1 undef, label [[BB18]], label [[BB7:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[BB18]], label [[BB7:%.*]]
 ; CHECK:       bb7:
 ; CHECK-NEXT:    br label [[BB9:%.*]]
 ; CHECK:       bb9:
-; CHECK-NEXT:    br i1 undef, label [[BB2]], label [[BB11:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[BB2]], label [[BB11:%.*]]
 ; CHECK:       bb11:
-; CHECK-NEXT:    br i1 undef, label [[BB16:%.*]], label [[BB14:%.*]]
+; CHECK-NEXT:    br i1 false, label [[BB16:%.*]], label [[BB14:%.*]]
 ; CHECK:       bb14:
 ; CHECK-NEXT:    br label [[BB4]]
 ; CHECK:       bb16:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[BB7]]
 ; CHECK:       bb18:
 ; CHECK-NEXT:    br label [[BB1]]
@@ -42,17 +43,17 @@ bb2:                                              ; preds = %bb9, %bb1
 
 bb4:                                              ; preds = %bb14, %bb2
   %tmp5 = phi i32 [ %tmp3, %bb2 ], [ %tmp15, %bb14 ]
-  br i1 undef, label %bb18, label %bb7
+  br i1 %arg, label %bb18, label %bb7
 
 bb7:                                              ; preds = %bb16, %bb4
   %tmp8 = phi i32 [ %tmp17, %bb16 ], [ %tmp5, %bb4 ]
   br label %bb9
 
 bb9:                                              ; preds = %bb7
-  br i1 undef, label %bb2, label %bb11
+  br i1 %arg, label %bb2, label %bb11
 
 bb11:                                             ; preds = %bb9
-  br i1 undef, label %bb16, label %bb14
+  br i1 %arg, label %bb16, label %bb14
 
 bb14:                                             ; preds = %bb11
   %tmp15 = phi i32 [ %tmp8, %bb11 ]
diff --git a/llvm/test/Transforms/NewGVN/pr31682.ll b/llvm/test/Transforms/NewGVN/pr31682.ll
index 3d8c9e28635c66..2f0d35a1611d28 100644
--- a/llvm/test/Transforms/NewGVN/pr31682.ll
+++ b/llvm/test/Transforms/NewGVN/pr31682.ll
@@ -6,13 +6,13 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 @global = external global ptr
 
-define void @bar() {
+define void @bar(i1 %arg) {
 ; CHECK-LABEL: @bar(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    [[TMP:%.*]] = load ptr, ptr @global, align 8
 ; CHECK-NEXT:    br label [[BB2:%.*]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    br i1 undef, label [[BB2]], label [[BB7:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[BB2]], label [[BB7:%.*]]
 ; CHECK:       bb7:
 ; CHECK-NEXT:    br label [[BB10:%.*]]
 ; CHECK:       bb10:
@@ -28,7 +28,7 @@ bb2:                                              ; preds = %bb2, %bb
   %tmp4 = getelementptr %struct.foo, ptr %tmp3, i64 0, i32 1
   %tmp5 = load i32, ptr %tmp4
   %tmp6 = load ptr, ptr @global
-  br i1 undef, label %bb2, label %bb7
+  br i1 %arg, label %bb2, label %bb7
 
 bb7:                                              ; preds = %bb2
   %tmp8 = phi ptr [ %tmp6, %bb2 ]
diff --git a/llvm/test/Transforms/NewGVN/pr32403.ll b/llvm/test/Transforms/NewGVN/pr32403.ll
index 90a2907d02ca77..0c2b9df7b8b2cb 100644
--- a/llvm/test/Transforms/NewGVN/pr32403.ll
+++ b/llvm/test/Transforms/NewGVN/pr32403.ll
@@ -4,23 +4,26 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.12.0"
 
 ; Function Attrs: nounwind ssp uwtable
-define void @reorder_ref_pic_list() local_unnamed_addr {
+define void @reorder_ref_pic_list(i1 %arg) local_unnamed_addr {
 ; CHECK-LABEL: @reorder_ref_pic_list(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
 ; CHECK:       for.body.preheader:
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
 ; CHECK:       for.body:
 ; CHECK-NEXT:    [[REFIDXLX_0:%.*]] = phi i32 [ [[INC_I51:%.*]], [[IF_ELSE58:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN13:%.*]], label [[IF_ELSE58]]
+; CHECK-NEXT:    br i1 false, label [[IF_THEN13:%.*]], label [[IF_ELSE58]]
 ; CHECK:       if.then13:
-; CHECK-NEXT:    [[INC_I:%.*]] = add nsw i32 [[REFIDXLX_0]], 1
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_BODY8_I:%.*]]
 ; CHECK:       for.body8.i:
-; CHECK-NEXT:    br i1 undef, label [[FOR_INC24_I:%.*]], label [[IF_THEN17_I:%.*]]
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
+; CHECK-NEXT:    br i1 false, label [[FOR_INC24_I:%.*]], label [[IF_THEN17_I:%.*]]
 ; CHECK:       if.then17.i:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_INC24_I]]
 ; CHECK:       for.inc24.i:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_BODY8_I]]
 ; CHECK:       if.else58:
 ; CHECK-NEXT:    [[INC_I51]] = add nsw i32 [[REFIDXLX_0]], 1
@@ -29,14 +32,14 @@ define void @reorder_ref_pic_list() local_unnamed_addr {
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  br i1 undef, label %for.end, label %for.body.preheader
+  br i1 %arg, label %for.end, label %for.body.preheader
 
 for.body.preheader:                               ; preds = %entry
   br label %for.body
 
 for.body:                                         ; preds = %if.else58, %for.body.preheader
   %refIdxLX.0 = phi i32 [ %inc.i51, %if.else58 ], [ 0, %for.body.preheader ]
-  br i1 undef, label %if.then13, label %if.else58
+  br i1 %arg, label %if.then13, label %if.else58
 
 if.then13:                                        ; preds = %for.body
   %inc.i = add nsw i32 %refIdxLX.0, 1
@@ -44,7 +47,7 @@ if.then13:                                        ; preds = %for.body
 
 for.body8.i:                                      ; preds = %for.inc24.i, %if.then13
   %nIdx.052.i = phi i32 [ %inc.i, %if.then13 ], [ %nIdx.1.i, %for.inc24.i ]
-  br i1 undef, label %for.inc24.i, label %if.then17.i
+  br i1 %arg, label %for.inc24.i, label %if.then17.i
 
 if.then17.i:                                      ; preds = %for.body8.i
   br label %for.inc24.i
diff --git a/llvm/test/Transforms/NewGVN/pr32838.ll b/llvm/test/Transforms/NewGVN/pr32838.ll
index 87c93d9312e67c..f73a7e3cb878d2 100644
--- a/llvm/test/Transforms/NewGVN/pr32838.ll
+++ b/llvm/test/Transforms/NewGVN/pr32838.ll
@@ -3,17 +3,17 @@
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.12.0"
 ;; Ensure we don't infinite loop when all phi arguments are really unreachable or self-defined
-define void @fn1(i64 noundef %arg) {
+define void @fn1(i64 noundef %arg, i1 %arg2) {
 ; CHECK-LABEL: @fn1(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]
 ; CHECK:       firstphiblock:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK:%.*]]
 ; CHECK:       secondphiblock:
 ; CHECK-NEXT:    [[SECONDPHI:%.*]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ undef, [[FIRSTPHIBLOCK]] ]
-; CHECK-NEXT:    br i1 undef, label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
 ; CHECK:       thirdphiblock:
 ; CHECK-NEXT:    [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]
 ; CHECK-NEXT:    br label [[SECONDPHIBLOCK]]
@@ -26,15 +26,15 @@ define void @fn1(i64 noundef %arg) {
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  br i1 undef, label %if.then, label %cond.true
+  br i1 %arg2, label %if.then, label %cond.true
 if.then:
   br i1 false, label %firstphiblock, label %temp
 firstphiblock:
   %firstphi = phi i64 [ %arg, %if.then ], [ undef, %secondphiblock ]
-  br i1 undef, label %for.cond17thread-pre-split, label %secondphiblock
+  br i1 %arg2, label %for.cond17thread-pre-split, label %secondphiblock
 secondphiblock:
   %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]
-  br i1 undef, label %firstphiblock, label %thirdphiblock
+  br i1 %arg2, label %firstphiblock, label %thirdphiblock
 thirdphiblock:
   %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]
   br label %secondphiblock
@@ -47,18 +47,18 @@ cond.true:
 temp:
   ret void
 }
-define void @fn2(i64 noundef %arg) {
+define void @fn2(i64 noundef %arg, i1 %arg2) {
 ; CHECK-LABEL: @fn2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]
 ; CHECK:       firstphiblock:
 ; CHECK-NEXT:    [[FIRSTPHI:%.*]] = phi i64 [ poison, [[IF_THEN]] ], [ [[SECONDPHI:%.*]], [[SECONDPHIBLOCK:%.*]] ]
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK]]
 ; CHECK:       secondphiblock:
 ; CHECK-NEXT:    [[SECONDPHI]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ [[FIRSTPHI]], [[FIRSTPHIBLOCK]] ]
-; CHECK-NEXT:    br i1 undef, label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]
 ; CHECK:       thirdphiblock:
 ; CHECK-NEXT:    [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]
 ; CHECK-NEXT:    br label [[SECONDPHIBLOCK]]
@@ -72,15 +72,15 @@ define void @fn2(i64 noundef %arg) {
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  br i1 undef, label %if.then, label %cond.true
+  br i1 %arg2, label %if.then, label %cond.true
 if.then:
   br i1 false, label %firstphiblock, label %temp
 firstphiblock:
   %firstphi = phi i64 [ %arg, %if.then ], [ %secondphi, %secondphiblock ]
-  br i1 undef, label %for.cond17thread-pre-split, label %secondphiblock
+  br i1 %arg2, label %for.cond17thread-pre-split, label %secondphiblock
 secondphiblock:
   %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]
-  br i1 undef, label %firstphiblock, label %thirdphiblock
+  br i1 %arg2, label %firstphiblock, label %thirdphiblock
 thirdphiblock:
   %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]
   br label %secondphiblock
@@ -95,7 +95,7 @@ temp:
 }
 @b = external global i32, align 4
 @a = external global i32, align 4
-define void @fn3() {
+define void @fn3(i1 %arg) {
 ; CHECK-LABEL: @fn3(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[L1:%.*]]
@@ -108,16 +108,15 @@ define void @fn3() {
 ; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_COND]]
 ; CHECK:       for.cond:
-; CHECK-NEXT:    br i1 undef, label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]
 ; CHECK:       for.cond1.preheader:
 ; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
 ; CHECK:       for.cond1:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[L2:%.*]]
 ; CHECK:       for.body3:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
+; CHECK-NEXT:    br i1 false, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
 ; CHECK:       l2:
-; CHECK-NEXT:    [[G_4:%.*]] = phi ptr [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
-; CHECK-NEXT:    [[F_2:%.*]] = phi ptr [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
 ; CHECK-NEXT:    br label [[FOR_INC:%.*]]
 ; CHECK:       for.inc:
 ; CHECK-NEXT:    br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]
@@ -138,13 +137,13 @@ for.cond.loopexit:
 for.cond:
   %g.1 = phi ptr [ %g.0, %l1 ], [ %g.4, %for.cond.loopexit ]
   %f.1 = phi ptr [ %f.0, %l1 ], [ %f.2, %for.cond.loopexit ]
-  br i1 undef, label %for.end14, label %for.cond1.preheader
+  br i1 %arg, label %for.end14, label %for.cond1.preheader
 for.cond1.preheader:
   br label %for.body3
 for.cond1:
   br label %l2
 for.body3:
-  br i1 undef, label %for.cond1, label %l1.loopexit
+  br i1 %arg, label %for.cond1, label %l1.loopexit
 l2:
   %g.4 = phi ptr [ %g.1, %for.end14 ], [ @a, %for.cond1 ]
   %f.2 = phi ptr [ %f.1, %for.end14 ], [ @a, %for.cond1 ]
diff --git a/llvm/test/Transforms/NewGVN/pr32845.ll b/llvm/test/Transforms/NewGVN/pr32845.ll
index 29b81b8e1c66a4..487ea904ebb91b 100644
--- a/llvm/test/Transforms/NewGVN/pr32845.ll
+++ b/llvm/test/Transforms/NewGVN/pr32845.ll
@@ -3,7 +3,7 @@
 
 @b = external global i32, align 4
 @a = external global i32, align 4
-define void @tinkywinky() {
+define void @tinkywinky(i1 %arg) {
 ; CHECK-LABEL: @tinkywinky(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[L1:%.*]]
@@ -16,16 +16,15 @@ define void @tinkywinky() {
 ; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_COND]]
 ; CHECK:       for.cond:
-; CHECK-NEXT:    br i1 undef, label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]
 ; CHECK:       for.cond1.preheader:
 ; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
 ; CHECK:       for.cond1:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[L2:%.*]]
 ; CHECK:       for.body3:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
+; CHECK-NEXT:    br i1 false, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
 ; CHECK:       l2:
-; CHECK-NEXT:    [[G_4:%.*]] = phi ptr [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
-; CHECK-NEXT:    [[F_2:%.*]] = phi ptr [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
 ; CHECK-NEXT:    br label [[FOR_INC:%.*]]
 ; CHECK:       for.inc:
 ; CHECK-NEXT:    br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]
@@ -46,13 +45,13 @@ for.cond.loopexit:
 for.cond:
   %g.1 = phi ptr [ %g.0, %l1 ], [ %g.4, %for.cond.loopexit ]
   %f.1 = phi ptr [ %f.0, %l1 ], [ %f.2, %for.cond.loopexit ]
-  br i1 undef, label %for.end14, label %for.cond1.preheader
+  br i1 %arg, label %for.end14, label %for.cond1.preheader
 for.cond1.preheader:
   br label %for.body3
 for.cond1:
   br label %l2
 for.body3:
-  br i1 undef, label %for.cond1, label %l1.loopexit
+  br i1 %arg, label %for.cond1, label %l1.loopexit
 l2:
   %g.4 = phi ptr [ %g.1, %for.end14 ], [ @a, %for.cond1 ]
   %f.2 = phi ptr [ %f.1, %for.end14 ], [ @a, %for.cond1 ]
diff --git a/llvm/test/Transforms/NewGVN/pr32897.ll b/llvm/test/Transforms/NewGVN/pr32897.ll
index 881c3a8e3ef538..5b3dc9a07bd233 100644
--- a/llvm/test/Transforms/NewGVN/pr32897.ll
+++ b/llvm/test/Transforms/NewGVN/pr32897.ll
@@ -1,13 +1,13 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -passes=newgvn %s | FileCheck %s
 
-define void @tinkywinky(ptr %b) {
+define void @tinkywinky(ptr %b, i1 %arg) {
 ; CHECK-LABEL: @tinkywinky(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[BODY:%.*]]
 ; CHECK:       body:
 ; CHECK-NEXT:    store i64 undef, ptr [[B:%.*]], align 4
-; CHECK-NEXT:    br i1 undef, label [[BODY]], label [[END:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[BODY]], label [[END:%.*]]
 ; CHECK:       end:
 ; CHECK-NEXT:    br label [[BODY]]
 ;
@@ -19,7 +19,7 @@ body:
   %b2 = load i64, ptr %b
   %or = or i64 %b2, 0
   store i64 %or, ptr %b
-  br i1 undef, label %body, label %end
+  br i1 %arg, label %body, label %end
 end:
   br label %body
 }
diff --git a/llvm/test/Transforms/NewGVN/pr32934.ll b/llvm/test/Transforms/NewGVN/pr32934.ll
index c8218c209face4..ca1827e0561af2 100644
--- a/llvm/test/Transforms/NewGVN/pr32934.ll
+++ b/llvm/test/Transforms/NewGVN/pr32934.ll
@@ -4,8 +4,8 @@
 
 @a = external global i32, align 4
 @patatino = external unnamed_addr constant [2 x i8], align 1
-define void @tinkywinky() {
-; CHECK-LABEL: define void @tinkywinky() {
+define void @tinkywinky(i1 %arg) {
+; CHECK-LABEL: define void @tinkywinky(i1 %arg) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[D:%.*]] = alloca i32, align 4
 ; CHECK-NEXT:    store i32 0, ptr null, align 4
@@ -27,7 +27,7 @@ define void @tinkywinky() {
 ; CHECK:       if.end:
 ; CHECK-NEXT:    br label [[FOR_COND]]
 ; CHECK:       while.cond:
-; CHECK-NEXT:    br i1 undef, label [[WHILE_BODY:%.*]], label [[WHILE_END:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[WHILE_BODY:%.*]], label [[WHILE_END:%.*]]
 ; CHECK:       while.body:
 ; CHECK-NEXT:    call void (ptr, ...) @printf(ptr @patatino)
 ; CHECK-NEXT:    br label [[WHILE_COND]]
@@ -58,7 +58,7 @@ if.then:
 if.end:
   br label %for.cond
 while.cond:
-  br i1 undef, label %while.body, label %while.end
+  br i1 %arg, label %while.body, label %while.end
 while.body:
   call void (ptr, ...) @printf(ptr @patatino)
   br label %while.cond
diff --git a/llvm/test/Transforms/NewGVN/pr33014.ll b/llvm/test/Transforms/NewGVN/pr33014.ll
index 04f9df2704a6c7..f0e02e8fcea517 100644
--- a/llvm/test/Transforms/NewGVN/pr33014.ll
+++ b/llvm/test/Transforms/NewGVN/pr33014.ll
@@ -5,16 +5,16 @@
 @c = external global i64, align 8
 
 
-define void @tinkywinky() {
-; CHECK-LABEL: define void @tinkywinky() {
+define void @tinkywinky(i1 %arg) {
+; CHECK-LABEL: define void @tinkywinky(i1 %arg) {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[L2:%.*]], label [[IF_THEN:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[L2:%.*]], label [[IF_THEN:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
 ; CHECK:       ph:
 ; CHECK-NEXT:    br label [[FOR_BODY]]
 ; CHECK:       for.body:
-; CHECK-NEXT:    br i1 undef, label [[ONTRUE:%.*]], label [[ONFALSE:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[ONTRUE:%.*]], label [[ONFALSE:%.*]]
 ; CHECK:       onfalse:
 ; CHECK-NEXT:    [[PATATINO:%.*]] = load i64, ptr @c, align 4
 ; CHECK-NEXT:    ret void
@@ -30,13 +30,13 @@ define void @tinkywinky() {
 ; CHECK-NEXT:    br i1 false, label [[BACK:%.*]], label [[END:%.*]]
 ;
 entry:
-  br i1 undef, label %l2, label %if.then
+  br i1 %arg, label %l2, label %if.then
 if.then:
   br label %for.body
 ph:
   br label %for.body
 for.body:
-  br i1 undef, label %ontrue, label %onfalse
+  br i1 %arg, label %ontrue, label %onfalse
 onfalse:
   %patatino = load i64, ptr @c
   store i64 %patatino, ptr @c
diff --git a/llvm/test/Transforms/NewGVN/pr33086.ll b/llvm/test/Transforms/NewGVN/pr33086.ll
index ab6c00dd1777ff..228bffb1ed12e9 100644
--- a/llvm/test/Transforms/NewGVN/pr33086.ll
+++ b/llvm/test/Transforms/NewGVN/pr33086.ll
@@ -3,10 +3,10 @@
 ; REQUIRES: asserts
 
 
-define void @tinkywinky() {
-; CHECK-LABEL: define void @tinkywinky() {
+define void @tinkywinky(i1 %arg) {
+; CHECK-LABEL: define void @tinkywinky(i1 %arg) {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND18:%.*]], label [[FOR_COND_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[FOR_COND18:%.*]], label [[FOR_COND_PREHEADER:%.*]]
 ; CHECK:       for.cond.preheader:
 ; CHECK-NEXT:    br label [[FOR_COND2THREAD_PRE_SPLIT:%.*]]
 ; CHECK:       for.cond2thread-pre-split:
@@ -28,7 +28,7 @@ define void @tinkywinky() {
 ; CHECK-NEXT:    br label [[L1]]
 ;
 entry:
-  br i1 undef, label %for.cond18, label %for.cond.preheader
+  br i1 %arg, label %for.cond18, label %for.cond.preheader
 
 for.cond.preheader:
   br label %for.cond2thread-pre-split
diff --git a/llvm/test/Transforms/NewGVN/pr33116.ll b/llvm/test/Transforms/NewGVN/pr33116.ll
index 6609ef9e72dac6..a0dc3b2382f913 100644
--- a/llvm/test/Transforms/NewGVN/pr33116.ll
+++ b/llvm/test/Transforms/NewGVN/pr33116.ll
@@ -3,15 +3,15 @@
 
 @a = external global i32
 
-define void @b() {
+define void @b(i1 %arg) {
 ; CHECK-LABEL: @b(
 ; CHECK-NEXT:    br i1 false, label [[C:%.*]], label [[WHILE_D:%.*]]
 ; CHECK:       while.d:
 ; CHECK-NEXT:    br label [[F:%.*]]
 ; CHECK:       f:
-; CHECK-NEXT:    br i1 undef, label [[IF_E:%.*]], label [[C]]
+; CHECK-NEXT:    br i1 %arg, label [[IF_E:%.*]], label [[C]]
 ; CHECK:       c:
-; CHECK-NEXT:    br i1 undef, label [[IF_G:%.*]], label [[IF_E]]
+; CHECK-NEXT:    br i1 %arg, label [[IF_G:%.*]], label [[IF_E]]
 ; CHECK:       if.g:
 ; CHECK-NEXT:    store i32 undef, ptr @a, align 4
 ; CHECK-NEXT:    br label [[WHILE_D]]
@@ -24,10 +24,10 @@ while.d:                                          ; preds = %if.g, %0
   br label %f
 
 f:                                                ; preds = %if.e, %while.d
-  br i1 undef, label %if.e, label %c
+  br i1 %arg, label %if.e, label %c
 
 c:                                                ; preds = %f, %0
-  br i1 undef, label %if.g, label %if.e
+  br i1 %arg, label %if.g, label %if.e
 
 if.g:                                             ; preds = %c
   store i32 undef, ptr @a
diff --git a/llvm/test/Transforms/NewGVN/pr33187.ll b/llvm/test/Transforms/NewGVN/pr33187.ll
index 37668bba3d5b60..969f172cba9560 100644
--- a/llvm/test/Transforms/NewGVN/pr33187.ll
+++ b/llvm/test/Transforms/NewGVN/pr33187.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ;; Ensure we don't change after value numbering by accidentally deleting the wrong expression.
 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
-define void @fn1() local_unnamed_addr #0 {
+define void @fn1(i1 %arg) local_unnamed_addr #0 {
 ; CHECK-LABEL: @fn1(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[FOR_COND_PREHEADER:%.*]]
@@ -16,27 +16,27 @@ define void @fn1() local_unnamed_addr #0 {
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br i1 false, label [[L_LOOPEXIT:%.*]], label [[IF_END:%.*]]
 ; CHECK:       if.end:
-; CHECK-NEXT:    br i1 undef, label [[FOR_INC]], label [[IF_END9:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_INC]], label [[IF_END9:%.*]]
 ; CHECK:       if.end9:
 ; CHECK-NEXT:    br label [[FOR_INC]]
 ; CHECK:       for.inc:
 ; CHECK-NEXT:    [[H_2]] = phi i32 [ [[H_128]], [[IF_END]] ], [ 0, [[IF_END9]] ]
-; CHECK-NEXT:    br i1 undef, label [[WHILE_COND10_LOOPEXIT:%.*]], label [[FOR_BODY]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[WHILE_COND10_LOOPEXIT:%.*]], label [[FOR_BODY]]
 ; CHECK:       while.cond10.loopexit:
 ; CHECK-NEXT:    br label [[WHILE_COND10:%.*]]
 ; CHECK:       while.cond10:
 ; CHECK-NEXT:    [[H_127]] = phi i32 [ [[H_126:%.*]], [[IF_END18:%.*]] ], [ [[H_125:%.*]], [[L:%.*]] ], [ [[H_2]], [[WHILE_COND10_LOOPEXIT]] ]
-; CHECK-NEXT:    br i1 undef, label [[WHILE_COND]], label [[WHILE_BODY12:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[WHILE_COND]], label [[WHILE_BODY12:%.*]]
 ; CHECK:       while.body12:
-; CHECK-NEXT:    br i1 undef, label [[IF_END18]], label [[L]]
+; CHECK-NEXT:    br i1 false, label [[IF_END18]], label [[L]]
 ; CHECK:       L.loopexit:
 ; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[L]]
 ; CHECK:       L:
 ; CHECK-NEXT:    [[H_125]] = phi i32 [ [[H_127]], [[WHILE_BODY12]] ], [ poison, [[L_LOOPEXIT]] ]
-; CHECK-NEXT:    br i1 undef, label [[WHILE_COND10]], label [[IF_END18]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[WHILE_COND10]], label [[IF_END18]]
 ; CHECK:       if.end18:
-; CHECK-NEXT:    [[H_126]] = phi i32 [ [[H_125]], [[L]] ], [ [[H_127]], [[WHILE_BODY12]] ]
+; CHECK-NEXT:    [[H_126]] = phi i32 [ [[H_125]], [[L]] ], [ poison, [[WHILE_BODY12]] ]
 ; CHECK-NEXT:    br label [[WHILE_COND10]]
 ;
 entry:
@@ -57,14 +57,14 @@ if.then:                                          ; preds = %for.body
   br i1 false, label %L.loopexit, label %if.end
 
 if.end:                                           ; preds = %if.then
-  br i1 undef, label %for.inc, label %if.end9
+  br i1 %arg, label %for.inc, label %if.end9
 
 if.end9:                                          ; preds = %if.end
   br label %for.inc
 
 for.inc:                                          ; preds = %if.end9, %if.end
   %h.2 = phi i32 [ %h.128, %if.end ], [ 0, %if.end9 ]
-  br i1 undef, label %while.cond10.loopexit, label %for.body
+  br i1 %arg, label %while.cond10.loopexit, label %for.body
 
 while.cond10.loopexit:                            ; preds = %for.inc
   %h.2.lcssa = phi i32 [ %h.2, %for.inc ]
@@ -72,17 +72,17 @@ while.cond10.loopexit:                            ; preds = %for.inc
 
 while.cond10:                                     ; preds = %if.end18, %L, %while.cond10.loopexit
   %h.127 = phi i32 [ %h.126, %if.end18 ], [ %h.125, %L ], [ %h.2.lcssa, %while.cond10.loopexit ]
-  br i1 undef, label %while.cond, label %while.body12
+  br i1 %arg, label %while.cond, label %while.body12
 
 while.body12:                                     ; preds = %while.cond10
-  br i1 undef, label %if.end18, label %L
+  br i1 %arg, label %if.end18, label %L
 
 L.loopexit:                                       ; preds = %if.then
   br label %L
 
 L:                                                ; preds = %L.loopexit, %while.body12
   %h.125 = phi i32 [ %h.127, %while.body12 ], [ undef, %L.loopexit ]
-  br i1 undef, label %while.cond10, label %if.end18
+  br i1 %arg, label %while.cond10, label %if.end18
 
 if.end18:                                         ; preds = %L, %while.body12
   %h.126 = phi i32 [ %h.125, %L ], [ %h.127, %while.body12 ]
@@ -111,14 +111,14 @@ bb1:                                              ; preds = %bb1, %bb
 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
 
 
-define void @a() {
+define void @a(i1 %arg) {
 ; CHECK-LABEL: @a(
 ; CHECK-NEXT:  b:
 ; CHECK-NEXT:    store ptr null, ptr null, align 8
 ; CHECK-NEXT:    br label [[D:%.*]]
 ; CHECK:       d:
 ; CHECK-NEXT:    [[I:%.*]] = phi ptr [ null, [[B:%.*]] ], [ [[E:%.*]], [[F:%.*]] ]
-; CHECK-NEXT:    br i1 undef, label [[F]], label [[G:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[F]], label [[G:%.*]]
 ; CHECK:       g:
 ; CHECK-NEXT:    store ptr [[I]], ptr null, align 8
 ; CHECK-NEXT:    unreachable
@@ -132,7 +132,7 @@ b:
 
 d:                                                ; preds = %f, %b
   %i = phi ptr [ null, %b ], [ %e, %f ]
-  br i1 undef, label %f, label %g
+  br i1 %arg, label %f, label %g
 
 g:                                                ; preds = %d
   %h = phi ptr [ %i, %d ]
diff --git a/llvm/test/Transforms/NewGVN/pr33204.ll b/llvm/test/Transforms/NewGVN/pr33204.ll
index 482e35e7fdb11f..a57544cc7f557b 100644
--- a/llvm/test/Transforms/NewGVN/pr33204.ll
+++ b/llvm/test/Transforms/NewGVN/pr33204.ll
@@ -10,7 +10,7 @@ target triple = "x86_64-apple-darwin16.7.0"
 @global = external global i32 #0
 @global.1 = external global i32 #0
 
-define void @hoge(i32 %arg) {
+define void @hoge(i32 %arg, i1 %arg2) {
 ; CHECK-LABEL: @hoge(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB2:%.*]]
@@ -24,9 +24,9 @@ define void @hoge(i32 %arg) {
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb6:
 ; CHECK-NEXT:    store i32 [[TMP]], ptr @global.1, align 4, !h [[META0]]
-; CHECK-NEXT:    br i1 undef, label [[BB7:%.*]], label [[BB1]]
+; CHECK-NEXT:    br i1 %arg2, label [[BB7:%.*]], label [[BB1]]
 ; CHECK:       bb7:
-; CHECK-NEXT:    br i1 undef, label [[BB10:%.*]], label [[BB8:%.*]]
+; CHECK-NEXT:    br i1 %arg2, label [[BB10:%.*]], label [[BB8:%.*]]
 ; CHECK:       bb8:
 ; CHECK-NEXT:    br i1 false, label [[BB9:%.*]], label [[BB3:%.*]]
 ; CHECK:       bb9:
@@ -53,10 +53,10 @@ bb3:                                              ; preds = %bb9, %bb8
 
 bb6:                                              ; preds = %bb2
   store i32 %tmp, ptr @global.1, !h !0
-  br i1 undef, label %bb7, label %bb1
+  br i1 %arg2, label %bb7, label %bb1
 
 bb7:                                              ; preds = %bb10, %bb6
-  br i1 undef, label %bb10, label %bb8
+  br i1 %arg2, label %bb10, label %bb8
 
 bb8:                                              ; preds = %bb7
   br i1 false, label %bb9, label %bb3
diff --git a/llvm/test/Transforms/NewGVN/pr33432.ll b/llvm/test/Transforms/NewGVN/pr33432.ll
index c03faef94a7489..5809e4bc82ed89 100644
--- a/llvm/test/Transforms/NewGVN/pr33432.ll
+++ b/llvm/test/Transforms/NewGVN/pr33432.ll
@@ -3,14 +3,14 @@
 ; Ensure we do not incorrect do phi of ops
 @d = external local_unnamed_addr global i32, align 4
 
-define void @patatino() {
+define void @patatino(i1 %arg) {
 ; CHECK-LABEL: @patatino(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @d, align 4
 ; CHECK-NEXT:    br label [[FOR_END10:%.*]]
 ; CHECK:       for.end10:
 ; CHECK-NEXT:    [[OR:%.*]] = or i32 [[TMP0]], 8
-; CHECK-NEXT:    br i1 undef, label [[IF_END:%.*]], label [[FOR_END10]]
+; CHECK-NEXT:    br i1 %arg, label [[IF_END:%.*]], label [[FOR_END10]]
 ; CHECK:       if.end:
 ; CHECK-NEXT:    ret void
 ;
@@ -22,7 +22,7 @@ for.end10:
   %f.0 = phi i32 [ undef, %entry ], [ 8, %for.end10 ]
   %or = or i32 %0, %f.0
   %mul12 = mul nsw i32 %or, undef
-  br i1 undef, label %if.end, label %for.end10
+  br i1 %arg, label %if.end, label %for.end10
 
 if.end:
   ret void
diff --git a/llvm/test/Transforms/NewGVN/pr33720.ll b/llvm/test/Transforms/NewGVN/pr33720.ll
index d1bcd311c5a0b1..5621148a120687 100644
--- a/llvm/test/Transforms/NewGVN/pr33720.ll
+++ b/llvm/test/Transforms/NewGVN/pr33720.ll
@@ -5,14 +5,14 @@
 @b = external local_unnamed_addr global i64
 @e = external local_unnamed_addr global i64
 
-define void @patatino() {
+define void @patatino(i1 %arg) {
 ; CHECK-LABEL: @patatino(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_END24:%.*]], label [[FOR_COND16:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[IF_END24:%.*]], label [[FOR_COND16:%.*]]
 ; CHECK:       for.cond2thread-pre-split:
 ; CHECK-NEXT:    br i1 false, label [[FOR_BODY:%.*]], label [[FOR_COND8_PREHEADER:%.*]]
 ; CHECK:       for.cond8.preheader:
-; CHECK-NEXT:    br i1 undef, label [[L1:%.*]], label [[FOR_COND11THREAD_PRE_SPLIT_LR_PH:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[L1:%.*]], label [[FOR_COND11THREAD_PRE_SPLIT_LR_PH:%.*]]
 ; CHECK:       for.cond11thread-pre-split.lr.ph:
 ; CHECK-NEXT:    br label [[L1]]
 ; CHECK:       for.body:
@@ -32,7 +32,7 @@ define void @patatino() {
 ; CHECK-NEXT:    br label [[FOR_BODY]]
 ; CHECK:       for.cond16:
 ; CHECK-NEXT:    [[J_0:%.*]] = phi ptr [ @f, [[ENTRY:%.*]] ], [ poison, [[FOR_COND20:%.*]] ], [ @e, [[FOR_COND16]] ]
-; CHECK-NEXT:    br i1 undef, label [[FOR_COND20]], label [[FOR_COND16]]
+; CHECK-NEXT:    br i1 %arg, label [[FOR_COND20]], label [[FOR_COND16]]
 ; CHECK:       for.cond20:
 ; CHECK-NEXT:    [[J_2:%.*]] = phi ptr [ [[J_0]], [[FOR_COND16]] ], [ poison, [[IF_END24]] ]
 ; CHECK-NEXT:    br i1 true, label [[IF_END24]], label [[FOR_COND16]]
@@ -43,13 +43,13 @@ define void @patatino() {
 ; CHECK-NEXT:    br label [[L1]]
 ;
 entry:
-  br i1 undef, label %if.end24, label %for.cond16
+  br i1 %arg, label %if.end24, label %for.cond16
 
 for.cond2thread-pre-split:
   br i1 false, label %for.body, label %for.cond8.preheader
 
 for.cond8.preheader:
-  br i1 undef, label %l1, label %for.cond11thread-pre-split.lr.ph
+  br i1 %arg, label %l1, label %for.cond11thread-pre-split.lr.ph
 
 for.cond11thread-pre-split.lr.ph:
   br label %l1
@@ -76,7 +76,7 @@ l1:
 
 for.cond16:
   %j.0 = phi ptr [ @f, %entry ], [ %j.2, %for.cond20 ], [ @e, %for.cond16 ]
-  br i1 undef, label %for.cond20, label %for.cond16
+  br i1 %arg, label %for.cond20, label %for.cond16
 
 for.cond20:
   %j.2 = phi ptr [ %j.0, %for.cond16 ], [ %j.3, %if.end24 ]
diff --git a/llvm/test/Transforms/NewGVN/pr34430.ll b/llvm/test/Transforms/NewGVN/pr34430.ll
index 490e29abe99ba3..490ba433305d5b 100644
--- a/llvm/test/Transforms/NewGVN/pr34430.ll
+++ b/llvm/test/Transforms/NewGVN/pr34430.ll
@@ -4,10 +4,10 @@
 source_filename = "bugpoint-output-e4c7d0f.bc"
 
 ;  Make sure we still properly resolve phi cycles when they involve predicateinfo copies of phis.
-define void @hoge() local_unnamed_addr #0 {
+define void @hoge(i1 %arg) local_unnamed_addr #0 {
 ; CHECK-LABEL: @hoge(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:    br i1 undef, label [[BB6:%.*]], label [[BB1:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[BB6:%.*]], label [[BB1:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    br label [[BB6]]
 ; CHECK:       bb2:
@@ -15,12 +15,12 @@ define void @hoge() local_unnamed_addr #0 {
 ; CHECK:       bb3:
 ; CHECK-NEXT:    br label [[BB4:%.*]]
 ; CHECK:       bb4:
-; CHECK-NEXT:    br i1 undef, label [[BB2:%.*]], label [[BB6]]
+; CHECK-NEXT:    br i1 %arg, label [[BB2:%.*]], label [[BB6]]
 ; CHECK:       bb6:
 ; CHECK-NEXT:    br label [[BB4]]
 ;
 bb:
-  br i1 undef, label %bb6, label %bb1
+  br i1 %arg, label %bb6, label %bb1
 
 bb1:                                              ; preds = %bb
   br label %bb6
@@ -34,7 +34,7 @@ bb3:                                              ; preds = %bb2
 
 bb4:                                              ; preds = %bb6, %bb3
   %tmp5 = phi i8 [ %tmp5, %bb3 ], [ %tmp7, %bb6 ]
-  br i1 undef, label %bb2, label %bb6
+  br i1 %arg, label %bb2, label %bb6
 
 bb6:                                              ; preds = %bb4, %bb2, %bb1, %bb
   %tmp7 = phi i8 [ %tmp5, %bb4 ], [ %tmp5, %bb2 ], [ 5, %bb1 ], [ undef, %bb ]
diff --git a/llvm/test/Transforms/NewGVN/pr35074.ll b/llvm/test/Transforms/NewGVN/pr35074.ll
index 1f5eb823b4a1d3..e55c471fd3eb03 100644
--- a/llvm/test/Transforms/NewGVN/pr35074.ll
+++ b/llvm/test/Transforms/NewGVN/pr35074.ll
@@ -1,12 +1,12 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
 
-define void @sort(i64 %.16) {
+define void @sort(i64 %.16, i1 %arg) {
 ; CHECK-LABEL: @sort(
 ; CHECK-NEXT:  Entry:
 ; CHECK-NEXT:    [[TMP0:%.*]] = extractvalue { i64, i1 } undef, 0
 ; CHECK-NEXT:    [[TMP1:%.*]] = lshr i64 [[TMP0]], 2
-; CHECK-NEXT:    br i1 undef, label [[DIVZEROFAIL2_I:%.*]], label [[WHILEBODY_LR_PH:%.*]]
+; CHECK-NEXT:    br i1 %arg, label [[DIVZEROFAIL2_I:%.*]], label [[WHILEBODY_LR_PH:%.*]]
 ; CHECK:       DivZeroFail2.i:
 ; CHECK-NEXT:    unreachable
 ; CHECK:       WhileBody.lr.ph:
@@ -30,7 +30,7 @@ define void @sort(i64 %.16) {
 Entry:
   %0 = extractvalue { i64, i1 } undef, 0
   %1 = lshr i64 %0, 2
-  br i1 undef, label %DivZeroFail2.i, label %WhileBody.lr.ph
+  br i1 %arg, label %DivZeroFail2.i, label %WhileBody.lr.ph
 
 DivZeroFail2.i:                                   ; preds = %Entry
   unreachable
diff --git a/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll b/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
index 1312f9f4f02967..ecc44e8718f302 100644
--- a/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
+++ b/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
@@ -1,25 +1,24 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
 
-define void @d() {
+define void @d(i1 %arg) {
 ; CHECK-LABEL: @d(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[FOR_COND:%.*]]
 ; CHECK:       for.cond:
 ; CHECK-NEXT:    br label [[FOR_COND1:%.*]]
 ; CHECK:       for.cond1:
-; CHECK-NEXT:    [[TMP0:%.*]] = phi i32 [ [[INC18:%.*]], [[FOR_INC17:%.*]] ], [ 0, [[FOR_COND]] ]
-; CHECK-NEXT:    [[CMP:%.*]] = icmp sle i32 [[TMP0]], 1
-; CHECK-NEXT:    br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END19:%.*]]
+; CHECK-NEXT:    br i1 true, label [[FOR_BODY:%.*]], label [[FOR_END19:%.*]]
 ; CHECK:       for.body:
-; CHECK-NEXT:    br i1 undef, label [[FOR_BODY3:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_BODY3:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE:%.*]]
 ; CHECK:       for.body.for.cond4_crit_edge:
 ; CHECK-NEXT:    br label [[FOR_COND4:%.*]]
 ; CHECK:       for.body3:
 ; CHECK-NEXT:    br label [[CLEANUP14:%.*]]
 ; CHECK:       for.cond4:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK-NEXT:    br i1 false, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 ; CHECK:       if.then:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       if.end:
 ; CHECK-NEXT:    br label [[FOR_COND6:%.*]]
@@ -38,26 +37,23 @@ define void @d() {
 ; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP]]
 ; CHECK:       cleanup:
-; CHECK-NEXT:    [[CLEANUP_DEST:%.*]] = phi i32 [ poison, [[IF_END12]] ], [ 1, [[IF_THEN11]] ], [ 9, [[IF_THEN]] ]
-; CHECK-NEXT:    switch i32 [[CLEANUP_DEST]], label [[CLEANUP14]] [
+; CHECK-NEXT:    switch i32 1, label [[CLEANUP14]] [
 ; CHECK-NEXT:      i32 0, label [[FOR_COND4]]
 ; CHECK-NEXT:      i32 9, label [[FOR_END13:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       for.end13:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP14]]
 ; CHECK:       cleanup14:
-; CHECK-NEXT:    [[CLEANUP_DEST15:%.*]] = phi i32 [ 0, [[FOR_END13]] ], [ [[CLEANUP_DEST]], [[CLEANUP]] ], [ 1, [[FOR_BODY3]] ]
-; CHECK-NEXT:    [[COND1:%.*]] = icmp eq i32 [[CLEANUP_DEST15]], 0
-; CHECK-NEXT:    br i1 [[COND1]], label [[FOR_INC17]], label [[CLEANUP20:%.*]]
+; CHECK-NEXT:    br i1 false, label [[FOR_INC17:%.*]], label [[CLEANUP20:%.*]]
 ; CHECK:       for.inc17:
-; CHECK-NEXT:    [[INC18]] = add nsw i32 [[TMP0]], 1
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_COND1]]
 ; CHECK:       for.end19:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP20]]
 ; CHECK:       cleanup20:
-; CHECK-NEXT:    [[PHIOFOPS:%.*]] = phi i1 [ true, [[FOR_END19]] ], [ [[COND1]], [[CLEANUP14]] ]
-; CHECK-NEXT:    [[CLEANUP_DEST21:%.*]] = phi i32 [ [[CLEANUP_DEST15]], [[CLEANUP14]] ], [ 0, [[FOR_END19]] ]
-; CHECK-NEXT:    br i1 [[PHIOFOPS]], label [[FOR_COND]], label [[CLEANUP23:%.*]]
+; CHECK-NEXT:    br i1 false, label [[FOR_COND]], label [[CLEANUP23:%.*]]
 ; CHECK:       cleanup23:
 ; CHECK-NEXT:    ret void
 ;
@@ -73,7 +69,7 @@ for.cond1:                                        ; preds = %for.inc17, %for.con
   br i1 %cmp, label %for.body, label %for.end19
 
 for.body:                                         ; preds = %for.cond1
-  br i1 undef, label %for.body3, label %for.body.for.cond4_crit_edge
+  br i1 %arg, label %for.body3, label %for.body.for.cond4_crit_edge
 
 for.body.for.cond4_crit_edge:                     ; preds = %for.body
   br label %for.cond4
@@ -82,7 +78,7 @@ for.body3:                                        ; preds = %for.body
   br label %cleanup14
 
 for.cond4:                                        ; preds = %cleanup, %for.body.for.cond4_crit_edge
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %for.cond4
   br label %cleanup
diff --git a/llvm/test/Transforms/NewGVN/pr43441.ll b/llvm/test/Transforms/NewGVN/pr43441.ll
index a5f711dbd69e5f..77c91754e7f96d 100644
--- a/llvm/test/Transforms/NewGVN/pr43441.ll
+++ b/llvm/test/Transforms/NewGVN/pr43441.ll
@@ -4,31 +4,35 @@
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-define dso_local void @print_long_format() #0 {
+define dso_local void @print_long_format(i32 %arg) #0 {
 ; CHECK-LABEL: define dso_local void @print_long_format(
-; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: i32 [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    switch i32 undef, label [[SW_DEFAULT:%.*]] [
+; CHECK-NEXT:    switch i32 0, label [[SW_DEFAULT:%.*]] [
 ; CHECK-NEXT:      i32 1, label [[SW_BB:%.*]]
 ; CHECK-NEXT:      i32 0, label [[SW_BB19:%.*]]
 ; CHECK-NEXT:      i32 2, label [[SW_BB23:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       sw.bb:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       sw.bb19:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN37:%.*]], label [[IF_END50:%.*]]
+; CHECK-NEXT:    br i1 false, label [[IF_THEN37:%.*]], label [[IF_END50:%.*]]
 ; CHECK:       sw.bb23:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       sw.default:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.then37:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end50:
 ; CHECK-NEXT:    [[CALL180:%.*]] = call i32 @timespec_cmp() #[[ATTR2:[0-9]+]]
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  switch i32 undef, label %sw.default [
+  switch i32 0, label %sw.default [
   i32 1, label %sw.bb
   i32 0, label %sw.bb19
   i32 2, label %sw.bb23
@@ -38,7 +42,7 @@ sw.bb:                                            ; preds = %entry
   unreachable
 
 sw.bb19:                                          ; preds = %entry
-  br i1 undef, label %if.then37, label %if.end50
+  br i1 false, label %if.then37, label %if.end50
 
 sw.bb23:                                          ; preds = %entry
   unreachable
diff --git a/llvm/test/Transforms/NewGVN/pre-new-inst-xfail.ll b/llvm/test/Transforms/NewGVN/pre-new-inst-xfail.ll
index f11d031b50aac3..50e22ba9ac4a56 100644
--- a/llvm/test/Transforms/NewGVN/pre-new-inst-xfail.ll
+++ b/llvm/test/Transforms/NewGVN/pre-new-inst-xfail.ll
@@ -2,10 +2,10 @@
 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
 
 %MyStruct = type { i32, i32 }
-define i8 @foo(i64 %in, ptr %arr) {
+define i8 @foo(i64 %in, ptr %arr, i1 %arg) {
   %addr = alloca %MyStruct
   %dead = trunc i64 %in to i32
-  br i1 undef, label %next, label %tmp
+  br i1 %arg, label %next, label %tmp
 
 tmp:
   call void @bar()
diff --git a/llvm/test/Transforms/NewGVN/predicates.ll b/llvm/test/Transforms/NewGVN/predicates.ll
index 26d08cb1316d4a..385fba8235ad10 100644
--- a/llvm/test/Transforms/NewGVN/predicates.ll
+++ b/llvm/test/Transforms/NewGVN/predicates.ll
@@ -82,7 +82,7 @@ define fastcc void @barney() {
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB22:%.*]]
 ; CHECK:       bb22:
-; CHECK-NEXT:    br i1 undef, label [[BB29:%.*]], label [[BB35:%.*]]
+; CHECK-NEXT:    br i1 true, label [[BB29:%.*]], label [[BB35:%.*]]
 ; CHECK:       bb29:
 ; CHECK-NEXT:    br i1 true, label [[BB33:%.*]], label [[BB35]]
 ; CHECK:       bb33:
@@ -93,16 +93,15 @@ define fastcc void @barney() {
 bb:
   br label %bb22
 bb22:                                             ; preds = %bb21
-  %tmp23 = icmp eq i32 undef, 2
-  br i1 %tmp23, label %bb29, label %bb35
+  br i1 true, label %bb29, label %bb35
 
 
 bb29:                                             ; preds = %bb28
-  br i1 %tmp23, label %bb33, label %bb35
+  br i1 true, label %bb33, label %bb35
 
 
 bb33:                                             ; preds = %bb31
-  br i1 %tmp23, label %bb35, label %bb35
+  br i1 true, label %bb35, label %bb35
 
 
 bb35:                                             ; preds = %bb33, %bb29, %bb22
diff --git a/llvm/test/Transforms/NewGVN/refine-stores.ll b/llvm/test/Transforms/NewGVN/refine-stores.ll
index 65a87e5a95f0a4..38d4dfde171b06 100644
--- a/llvm/test/Transforms/NewGVN/refine-stores.ll
+++ b/llvm/test/Transforms/NewGVN/refine-stores.ll
@@ -12,13 +12,13 @@ target triple = "x86_64-apple-darwin16.5.0"
 
 %struct.eggs = type {}
 
-define void @spam(ptr %a) {
+define void @spam(ptr %a, i1 %arg) {
 ; CHECK-LABEL: @spam(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    store ptr null, ptr [[A:%.*]], align 8
 ; CHECK-NEXT:    br label [[BB1:%.*]]
 ; CHECK:       bb1:
-; CHECK-NEXT:    br i1 undef, label [[BB3:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[BB3:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb2:
 ; CHECK-NEXT:    call void @baz()
 ; CHECK-NEXT:    br label [[BB1]]
@@ -32,7 +32,7 @@ bb:
   br label %bb1
 
 bb1:                                              ; preds = %bb2, %bb
-  br i1 undef, label %bb3, label %bb2
+  br i1 %arg, label %bb3, label %bb2
 
 bb2:                                              ; preds = %bb1
   call void @baz()
@@ -52,7 +52,7 @@ bb3:                                              ; preds = %bb1
 declare void @baz()
 
 
-define void @a() {
+define void @a(i1 %arg) {
 ; CHECK-LABEL: @a(
 ; CHECK-NEXT:  b:
 ; CHECK-NEXT:    br label [[C:%.*]]
@@ -61,7 +61,7 @@ define void @a() {
 ; CHECK-NEXT:    br label [[E:%.*]]
 ; CHECK:       e:
 ; CHECK-NEXT:    store ptr undef, ptr null, align 8
-; CHECK-NEXT:    br i1 undef, label [[C]], label [[E]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[C]], label [[E]]
 ;
 b:
   br label %c
@@ -76,19 +76,19 @@ e:                                                ; preds = %e, %c
 ;; need to make sure the right set of values get marked as changed after memory leaders change
   %g = load ptr, ptr null
   store ptr undef, ptr null
-  br i1 undef, label %c, label %e
+  br i1 %arg, label %c, label %e
 }
 
 %struct.hoge = type {}
 
-define void @widget(ptr %arg) {
+define void @widget(ptr %arg, i1 %arg2) {
 ; CHECK-LABEL: @widget(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
 ; CHECK:       bb1:
 ; CHECK-NEXT:    [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB1]] ]
 ; CHECK-NEXT:    store ptr [[TMP]], ptr undef, align 8
-; CHECK-NEXT:    br i1 undef, label [[BB1]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[BB1]], label [[BB2:%.*]]
 ; CHECK:       bb2:
 ; CHECK-NEXT:    [[TMP3:%.*]] = phi i64 [ [[TMP8:%.*]], [[BB7:%.*]] ], [ 0, [[BB1]] ]
 ; CHECK-NEXT:    [[TMP4:%.*]] = icmp eq i64 [[TMP3]], 0
@@ -108,7 +108,7 @@ bb:
 bb1:                                              ; preds = %bb1, %bb
   %tmp = phi ptr [ %arg, %bb ], [ null, %bb1 ]
   store ptr %tmp, ptr undef
-  br i1 undef, label %bb1, label %bb2
+  br i1 %arg2, label %bb1, label %bb2
 
 bb2:                                              ; preds = %bb7, %bb1
   %tmp3 = phi i64 [ %tmp8, %bb7 ], [ 0, %bb1 ]
@@ -132,7 +132,7 @@ declare void @quux()
 
 %struct.a = type {}
 
-define void @b() {
+define void @b(i1 %arg) {
 ; CHECK-LABEL: @b(
 ; CHECK-NEXT:    [[C:%.*]] = alloca [[STRUCT_A:%.*]], align 8
 ; CHECK-NEXT:    br label [[D:%.*]]
@@ -140,9 +140,9 @@ define void @b() {
 ; CHECK-NEXT:    unreachable
 ; CHECK:       d:
 ; CHECK-NEXT:    [[E:%.*]] = load i32, ptr [[C]], align 4
-; CHECK-NEXT:    br i1 undef, label [[I:%.*]], label [[J:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[I:%.*]], label [[J:%.*]]
 ; CHECK:       i:
-; CHECK-NEXT:    br i1 undef, label [[K:%.*]], label [[M:%.*]]
+; CHECK-NEXT:    br i1 true, label [[K:%.*]], label [[M:%.*]]
 ; CHECK:       k:
 ; CHECK-NEXT:    br label [[L:%.*]]
 ; CHECK:       l:
@@ -160,10 +160,10 @@ m:                                                ; preds = %j, %i
 d:                                                ; preds = %0
   %h = getelementptr i8, ptr %c
   %e = load i32, ptr %h
-  br i1 undef, label %i, label %j
+  br i1 %arg, label %i, label %j
 
 i:                                                ; preds = %d
-  br i1 undef, label %k, label %m
+  br i1 %arg, label %k, label %m
 
 k:                                                ; preds = %i
   br label %l
diff --git a/llvm/test/Transforms/NewGVN/stale-loop-info.ll b/llvm/test/Transforms/NewGVN/stale-loop-info.ll
index 7abe80b005ecf2..80724035adff1c 100644
--- a/llvm/test/Transforms/NewGVN/stale-loop-info.ll
+++ b/llvm/test/Transforms/NewGVN/stale-loop-info.ll
@@ -25,14 +25,15 @@ define hidden zeroext i1 @eggs(ptr %arg, i1 %arg2) unnamed_addr align 2 {
 ; CHECK:       bb6:
 ; CHECK-NEXT:    br label [[BB7:%.*]]
 ; CHECK:       bb7:
-; CHECK-NEXT:    br i1 undef, label [[BB11:%.*]], label [[BB8:%.*]]
+; CHECK-NEXT:    br i1 false, label [[BB11:%.*]], label [[BB8:%.*]]
 ; CHECK:       bb8:
 ; CHECK-NEXT:    [[TMP9:%.*]] = load ptr, ptr [[TMP]], align 8
 ; CHECK-NEXT:    br label [[BB12:%.*]]
 ; CHECK:       bb11:
+; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[BB12]]
 ; CHECK:       bb12:
-; CHECK-NEXT:    [[TMP13:%.*]] = phi ptr [ [[TMP]], [[BB11]] ], [ [[TMP9]], [[BB8]] ]
+; CHECK-NEXT:    [[TMP13:%.*]] = phi ptr [ poison, [[BB11]] ], [ [[TMP9]], [[BB8]] ]
 ; CHECK-NEXT:    call void @snork.1(ptr [[TMP13]]) #[[ATTR1:[0-9]+]]
 ; CHECK-NEXT:    br label [[BB6]]
 ; CHECK:       bb14:
@@ -49,7 +50,7 @@ bb6:                                              ; preds = %bb12, %bb3
   br label %bb7
 
 bb7:                                              ; preds = %bb6
-  br i1 undef, label %bb11, label %bb8
+  br i1 %arg2, label %bb11, label %bb8
 
 bb8:                                              ; preds = %bb7
   %tmp9 = load ptr, ptr %tmp, align 8
diff --git a/llvm/test/Transforms/NewGVN/unreachable_block_infinite_loop.ll b/llvm/test/Transforms/NewGVN/unreachable_block_infinite_loop.ll
index 70e5e1a138da7e..335ed92dad9c75 100644
--- a/llvm/test/Transforms/NewGVN/unreachable_block_infinite_loop.ll
+++ b/llvm/test/Transforms/NewGVN/unreachable_block_infinite_loop.ll
@@ -13,14 +13,14 @@ unreachable_block:
   ret i32 %a
 }
 
-define i32 @pr23096_test0() {
+define i32 @pr23096_test0(i1 %arg) {
 entry:
   br label %bb0
 
 bb1:
   %ptr1 = ptrtoint ptr %ptr2 to i64
   %ptr2 = inttoptr i64 %ptr1 to ptr
-  br i1 undef, label %bb0, label %bb1
+  br i1 %arg, label %bb0, label %bb1
 
 bb0:
   %phi = phi ptr [ undef, %entry ], [ %ptr2, %bb1 ]
@@ -28,14 +28,14 @@ bb0:
   ret i32 %load
 }
 
-define i32 @pr23096_test1() {
+define i32 @pr23096_test1(i1 %arg) {
 entry:
   br label %bb0
 
 bb1:
   %ptr1 = getelementptr i32, ptr %ptr2, i32 0
   %ptr2 = getelementptr i32, ptr %ptr1, i32 0
-  br i1 undef, label %bb0, label %bb1
+  br i1 %arg, label %bb0, label %bb1
 
 bb0:
   %phi = phi ptr [ undef, %entry ], [ %ptr2, %bb1 ]

>From 413f56e8d010690189d221d798c5c5d1773b68d8 Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Mon, 25 Nov 2024 22:17:25 -0700
Subject: [PATCH 4/7] Replace undef with different argument to avoid
 unreachable BB

---
 .../NewGVN/2010-03-31-RedundantPHIs.ll        | 14 ++++------
 .../Transforms/NewGVN/eliminate-ssacopy.ll    |  9 +++---
 llvm/test/Transforms/NewGVN/pr25440.ll        |  9 +++---
 llvm/test/Transforms/NewGVN/pr31594.ll        |  7 ++---
 llvm/test/Transforms/NewGVN/pr31613.ll        |  7 ++---
 llvm/test/Transforms/NewGVN/pr32403.ll        | 15 ++++------
 llvm/test/Transforms/NewGVN/pr32838.ll        |  9 +++---
 llvm/test/Transforms/NewGVN/pr32845.ll        |  9 +++---
 .../Transforms/NewGVN/pr42422-phi-of-ops.ll   | 28 +++++++++++--------
 llvm/test/Transforms/NewGVN/pr43441.ll        | 16 ++++-------
 10 files changed, 58 insertions(+), 65 deletions(-)

diff --git a/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll b/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
index 14a16a05e74ae7..7de5ecf3e4b2c7 100644
--- a/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
+++ b/llvm/test/Transforms/NewGVN/2010-03-31-RedundantPHIs.ll
@@ -4,19 +4,17 @@
 ; CHECK-NOT: load
 ; CHECK-NOT: phi
 
-define ptr @cat(ptr %s1, i1 %arg, ...) nounwind {
+define ptr @cat(ptr %s1, i1 %arg, i1 %arg2, i1 %arg3, ...) nounwind {
 ; CHECK-LABEL: define ptr @cat(
-; CHECK-SAME: ptr [[S1:%.*]], i1 [[ARG:%.*]], ...) #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: ptr [[S1:%.*]], i1 [[ARG:%.*]], i1 [[ARG2:%.*]], i1 [[ARG3:%.*]], ...) #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 false, label [[BB:%.*]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[BB:%.*]], label [[BB3:%.*]]
 ; CHECK:       bb:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb3:
 ; CHECK-NEXT:    store ptr undef, ptr undef, align 4
-; CHECK-NEXT:    br i1 false, label [[BB5:%.*]], label [[BB6:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3]], label [[BB5:%.*]], label [[BB6:%.*]]
 ; CHECK:       bb5:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb6:
 ; CHECK-NEXT:    br label [[BB12:%.*]]
@@ -35,14 +33,14 @@ define ptr @cat(ptr %s1, i1 %arg, ...) nounwind {
 ; CHECK-NEXT:    ret ptr undef
 ;
 entry:
-  br i1 false, label %bb, label %bb3
+  br i1 %arg2, label %bb, label %bb3
 
 bb:                                               ; preds = %entry
   unreachable
 
 bb3:                                              ; preds = %entry
   store ptr undef, ptr undef, align 4
-  br i1 false, label %bb5, label %bb6
+  br i1 %arg3, label %bb5, label %bb6
 
 bb5:                                              ; preds = %bb3
   unreachable
diff --git a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
index dd65861076c526..83992c5ba5bcda 100644
--- a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
+++ b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
@@ -9,12 +9,11 @@
 @a = external dso_local local_unnamed_addr global i8, align 1
 @f = external dso_local local_unnamed_addr global i16, align 2
 
-define void @g() {
+define void @g(i1 %arg) {
 ; CHECK-LABEL: @g(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 true, label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
 ; CHECK:       for.cond.preheader:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       for.cond1thread-pre-split:
 ; CHECK-NEXT:    br label [[FOR_END4_SPLIT:%.*]]
@@ -39,7 +38,7 @@ define void @g() {
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  br i1 true, label %for.cond1thread-pre-split, label %for.cond.preheader
+  br i1 %arg, label %for.cond1thread-pre-split, label %for.cond.preheader
 
 for.cond.preheader:                               ; preds = %entry
   unreachable
@@ -51,7 +50,7 @@ for.end4.split:                                   ; preds = %for.cond1thread-pre
   br i1 true, label %for.cond6.preheader, label %if.end11
 
 for.cond6.preheader:                              ; preds = %for.end4.split
-  br i1 true, label %for.cond6.preheader3, label %if.end11.loopexit
+  br i1 %arg, label %for.cond6.preheader3, label %if.end11.loopexit
 
 for.cond6.preheader3:                             ; preds = %for.cond6.preheader
   br label %if.end11.loopexit
diff --git a/llvm/test/Transforms/NewGVN/pr25440.ll b/llvm/test/Transforms/NewGVN/pr25440.ll
index fe87d134ec3d54..2cba2d8260fa4c 100644
--- a/llvm/test/Transforms/NewGVN/pr25440.ll
+++ b/llvm/test/Transforms/NewGVN/pr25440.ll
@@ -10,9 +10,9 @@ target triple = "thumbv7--linux-gnueabi"
 @length = external global [0 x i32], align 4
 
 ; Function Attrs: nounwind
-define fastcc void @foo(ptr nocapture readonly %x, i1 %arg) {
+define fastcc void @foo(ptr nocapture readonly %x, i1 %arg, i1 %arg2) {
 ; CHECK-LABEL: define fastcc void @foo(
-; CHECK-SAME: ptr nocapture readonly [[X:%.*]], i1 [[ARG:%.*]]) {
+; CHECK-SAME: ptr nocapture readonly [[X:%.*]], i1 [[ARG:%.*]], i1 [[ARG2:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[BB0:%.*]]
 ; CHECK:       bb0:
@@ -33,9 +33,8 @@ define fastcc void @foo(ptr nocapture readonly %x, i1 %arg) {
 ; CHECK-NEXT:    [[BF_LOAD:%.*]] = load i16, ptr [[MODE]], align 2
 ; CHECK-NEXT:    br label [[COND_END]]
 ; CHECK:       cond.end:
-; CHECK-NEXT:    br i1 false, label [[IF_THEN_44:%.*]], label [[CLEANUP]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[IF_THEN_44:%.*]], label [[CLEANUP]]
 ; CHECK:       if.then.44:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end.50:
 ; CHECK-NEXT:    [[ARRAYIDX52:%.*]] = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 [[CONV]]
@@ -76,7 +75,7 @@ cond.false:                                       ; preds = %if.then.26
   br label %cond.end
 
 cond.end:                                         ; preds = %cond.false, %if.then.26
-  br i1 false, label %if.then.44, label %cleanup
+  br i1 %arg2, label %if.then.44, label %cleanup
 
 if.then.44:                                       ; preds = %cond.end
   unreachable
diff --git a/llvm/test/Transforms/NewGVN/pr31594.ll b/llvm/test/Transforms/NewGVN/pr31594.ll
index 777bfbd6067f12..11cd8e6bd6f2a6 100644
--- a/llvm/test/Transforms/NewGVN/pr31594.ll
+++ b/llvm/test/Transforms/NewGVN/pr31594.ll
@@ -56,7 +56,7 @@ while.end:
 
 ;; This is an example of a case where the memory states are equivalent solely due to unreachability,
 ;; but the stores are not equal.
-define void @foo(ptr %arg, i1 %arg2) {
+define void @foo(ptr %arg, i1 %arg2, i1 %arg3) {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
@@ -71,9 +71,8 @@ define void @foo(ptr %arg, i1 %arg2) {
 ; CHECK:       bb4:
 ; CHECK-NEXT:    br label [[BB6:%.*]]
 ; CHECK:       bb6:
-; CHECK-NEXT:    br i1 true, label [[BB9:%.*]], label [[BB7:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3:%.*]], label [[BB9:%.*]], label [[BB7:%.*]]
 ; CHECK:       bb7:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    switch i8 0, label [[BB6]] [
 ; CHECK-NEXT:      i8 6, label [[BB8:%.*]]
 ; CHECK-NEXT:    ]
@@ -103,7 +102,7 @@ bb4:                                              ; preds = %bb8, %bb3
   br label %bb6
 
 bb6:                                              ; preds = %bb7, %bb4
-  br i1 %arg2, label %bb9, label %bb7
+  br i1 %arg3, label %bb9, label %bb7
 
 bb7:                                              ; preds = %bb6
   switch i8 0, label %bb6 [
diff --git a/llvm/test/Transforms/NewGVN/pr31613.ll b/llvm/test/Transforms/NewGVN/pr31613.ll
index 2db3024a0b3bd1..e1d27080e23976 100644
--- a/llvm/test/Transforms/NewGVN/pr31613.ll
+++ b/llvm/test/Transforms/NewGVN/pr31613.ll
@@ -5,7 +5,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 ;; Both of these tests are tests of phi nodes that end up all equivalent to each other
 ;; Without proper leader ordering, we will end up cycling the leader between all of them and never converge.
 
-define void @foo(i1 %arg) {
+define void @foo(i1 %arg, i1 %arg2) {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    br label [[BB1:%.*]]
@@ -21,11 +21,10 @@ define void @foo(i1 %arg) {
 ; CHECK:       bb9:
 ; CHECK-NEXT:    br i1 [[ARG]], label [[BB2]], label [[BB11:%.*]]
 ; CHECK:       bb11:
-; CHECK-NEXT:    br i1 false, label [[BB16:%.*]], label [[BB14:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[BB16:%.*]], label [[BB14:%.*]]
 ; CHECK:       bb14:
 ; CHECK-NEXT:    br label [[BB4]]
 ; CHECK:       bb16:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[BB7]]
 ; CHECK:       bb18:
 ; CHECK-NEXT:    br label [[BB1]]
@@ -53,7 +52,7 @@ bb9:                                              ; preds = %bb7
   br i1 %arg, label %bb2, label %bb11
 
 bb11:                                             ; preds = %bb9
-  br i1 %arg, label %bb16, label %bb14
+  br i1 %arg2, label %bb16, label %bb14
 
 bb14:                                             ; preds = %bb11
   %tmp15 = phi i32 [ %tmp8, %bb11 ]
diff --git a/llvm/test/Transforms/NewGVN/pr32403.ll b/llvm/test/Transforms/NewGVN/pr32403.ll
index 0c2b9df7b8b2cb..fb92732e1235b4 100644
--- a/llvm/test/Transforms/NewGVN/pr32403.ll
+++ b/llvm/test/Transforms/NewGVN/pr32403.ll
@@ -4,7 +4,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.12.0"
 
 ; Function Attrs: nounwind ssp uwtable
-define void @reorder_ref_pic_list(i1 %arg) local_unnamed_addr {
+define void @reorder_ref_pic_list(i1 %arg, i1 %arg2, i1 %arg3) local_unnamed_addr {
 ; CHECK-LABEL: @reorder_ref_pic_list(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_END:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
@@ -12,18 +12,15 @@ define void @reorder_ref_pic_list(i1 %arg) local_unnamed_addr {
 ; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
 ; CHECK:       for.body:
 ; CHECK-NEXT:    [[REFIDXLX_0:%.*]] = phi i32 [ [[INC_I51:%.*]], [[IF_ELSE58:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
-; CHECK-NEXT:    br i1 false, label [[IF_THEN13:%.*]], label [[IF_ELSE58]]
+; CHECK-NEXT:    br i1 [[ARG3:%.*]], label [[IF_THEN13:%.*]], label [[IF_ELSE58]]
 ; CHECK:       if.then13:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
+; CHECK-NEXT:    [[INC_I:%.*]] = add nsw i32 [[REFIDXLX_0]], 1
 ; CHECK-NEXT:    br label [[FOR_BODY8_I:%.*]]
 ; CHECK:       for.body8.i:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
-; CHECK-NEXT:    br i1 false, label [[FOR_INC24_I:%.*]], label [[IF_THEN17_I:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[FOR_INC24_I:%.*]], label [[IF_THEN17_I:%.*]]
 ; CHECK:       if.then17.i:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_INC24_I]]
 ; CHECK:       for.inc24.i:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[FOR_BODY8_I]]
 ; CHECK:       if.else58:
 ; CHECK-NEXT:    [[INC_I51]] = add nsw i32 [[REFIDXLX_0]], 1
@@ -39,7 +36,7 @@ for.body.preheader:                               ; preds = %entry
 
 for.body:                                         ; preds = %if.else58, %for.body.preheader
   %refIdxLX.0 = phi i32 [ %inc.i51, %if.else58 ], [ 0, %for.body.preheader ]
-  br i1 %arg, label %if.then13, label %if.else58
+  br i1 %arg2, label %if.then13, label %if.else58
 
 if.then13:                                        ; preds = %for.body
   %inc.i = add nsw i32 %refIdxLX.0, 1
@@ -47,7 +44,7 @@ if.then13:                                        ; preds = %for.body
 
 for.body8.i:                                      ; preds = %for.inc24.i, %if.then13
   %nIdx.052.i = phi i32 [ %inc.i, %if.then13 ], [ %nIdx.1.i, %for.inc24.i ]
-  br i1 %arg, label %for.inc24.i, label %if.then17.i
+  br i1 %arg3, label %for.inc24.i, label %if.then17.i
 
 if.then17.i:                                      ; preds = %for.body8.i
   br label %for.inc24.i
diff --git a/llvm/test/Transforms/NewGVN/pr32838.ll b/llvm/test/Transforms/NewGVN/pr32838.ll
index f73a7e3cb878d2..5b206cfabcf095 100644
--- a/llvm/test/Transforms/NewGVN/pr32838.ll
+++ b/llvm/test/Transforms/NewGVN/pr32838.ll
@@ -95,7 +95,7 @@ temp:
 }
 @b = external global i32, align 4
 @a = external global i32, align 4
-define void @fn3(i1 %arg) {
+define void @fn3(i1 %arg, i1 %arg2) {
 ; CHECK-LABEL: @fn3(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[L1:%.*]]
@@ -112,11 +112,12 @@ define void @fn3(i1 %arg) {
 ; CHECK:       for.cond1.preheader:
 ; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
 ; CHECK:       for.cond1:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[L2:%.*]]
 ; CHECK:       for.body3:
-; CHECK-NEXT:    br i1 false, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
 ; CHECK:       l2:
+; CHECK-NEXT:    [[G_4:%.*]] = phi ptr [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
+; CHECK-NEXT:    [[F_2:%.*]] = phi ptr [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
 ; CHECK-NEXT:    br label [[FOR_INC:%.*]]
 ; CHECK:       for.inc:
 ; CHECK-NEXT:    br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]
@@ -143,7 +144,7 @@ for.cond1.preheader:
 for.cond1:
   br label %l2
 for.body3:
-  br i1 %arg, label %for.cond1, label %l1.loopexit
+  br i1 %arg2, label %for.cond1, label %l1.loopexit
 l2:
   %g.4 = phi ptr [ %g.1, %for.end14 ], [ @a, %for.cond1 ]
   %f.2 = phi ptr [ %f.1, %for.end14 ], [ @a, %for.cond1 ]
diff --git a/llvm/test/Transforms/NewGVN/pr32845.ll b/llvm/test/Transforms/NewGVN/pr32845.ll
index 487ea904ebb91b..3f13ffad046374 100644
--- a/llvm/test/Transforms/NewGVN/pr32845.ll
+++ b/llvm/test/Transforms/NewGVN/pr32845.ll
@@ -3,7 +3,7 @@
 
 @b = external global i32, align 4
 @a = external global i32, align 4
-define void @tinkywinky(i1 %arg) {
+define void @tinkywinky(i1 %arg, i1 %arg2) {
 ; CHECK-LABEL: @tinkywinky(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[L1:%.*]]
@@ -20,11 +20,12 @@ define void @tinkywinky(i1 %arg) {
 ; CHECK:       for.cond1.preheader:
 ; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
 ; CHECK:       for.cond1:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[L2:%.*]]
 ; CHECK:       for.body3:
-; CHECK-NEXT:    br i1 false, label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]
 ; CHECK:       l2:
+; CHECK-NEXT:    [[G_4:%.*]] = phi ptr [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
+; CHECK-NEXT:    [[F_2:%.*]] = phi ptr [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]
 ; CHECK-NEXT:    br label [[FOR_INC:%.*]]
 ; CHECK:       for.inc:
 ; CHECK-NEXT:    br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]
@@ -51,7 +52,7 @@ for.cond1.preheader:
 for.cond1:
   br label %l2
 for.body3:
-  br i1 %arg, label %for.cond1, label %l1.loopexit
+  br i1 %arg2, label %for.cond1, label %l1.loopexit
 l2:
   %g.4 = phi ptr [ %g.1, %for.end14 ], [ @a, %for.cond1 ]
   %f.2 = phi ptr [ %f.1, %for.end14 ], [ @a, %for.cond1 ]
diff --git a/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll b/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
index ecc44e8718f302..b7264ef9575125 100644
--- a/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
+++ b/llvm/test/Transforms/NewGVN/pr42422-phi-of-ops.ll
@@ -1,24 +1,25 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
 
-define void @d(i1 %arg) {
+define void @d(i1 %arg, i1 %arg2) {
 ; CHECK-LABEL: @d(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[FOR_COND:%.*]]
 ; CHECK:       for.cond:
 ; CHECK-NEXT:    br label [[FOR_COND1:%.*]]
 ; CHECK:       for.cond1:
-; CHECK-NEXT:    br i1 true, label [[FOR_BODY:%.*]], label [[FOR_END19:%.*]]
+; CHECK-NEXT:    [[TMP0:%.*]] = phi i32 [ [[INC18:%.*]], [[FOR_INC17:%.*]] ], [ 0, [[FOR_COND]] ]
+; CHECK-NEXT:    [[ARG:%.*]] = icmp sle i32 [[TMP0]], 1
+; CHECK-NEXT:    br i1 [[ARG]], label [[FOR_BODY3:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE:%.*]]
 ; CHECK:       for.body:
-; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_BODY3:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE:%.*]]
+; CHECK-NEXT:    br i1 [[ARG1:%.*]], label [[FOR_BODY4:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE1:%.*]]
 ; CHECK:       for.body.for.cond4_crit_edge:
 ; CHECK-NEXT:    br label [[FOR_COND4:%.*]]
 ; CHECK:       for.body3:
 ; CHECK-NEXT:    br label [[CLEANUP14:%.*]]
 ; CHECK:       for.cond4:
-; CHECK-NEXT:    br i1 false, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 ; CHECK:       if.then:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       if.end:
 ; CHECK-NEXT:    br label [[FOR_COND6:%.*]]
@@ -37,23 +38,26 @@ define void @d(i1 %arg) {
 ; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP]]
 ; CHECK:       cleanup:
-; CHECK-NEXT:    switch i32 1, label [[CLEANUP14]] [
+; CHECK-NEXT:    [[CLEANUP_DEST:%.*]] = phi i32 [ poison, [[IF_END12]] ], [ 1, [[IF_THEN11]] ], [ 9, [[IF_THEN]] ]
+; CHECK-NEXT:    switch i32 [[CLEANUP_DEST]], label [[CLEANUP14]] [
 ; CHECK-NEXT:      i32 0, label [[FOR_COND4]]
 ; CHECK-NEXT:      i32 9, label [[FOR_END13:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       for.end13:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP14]]
 ; CHECK:       cleanup14:
-; CHECK-NEXT:    br i1 false, label [[FOR_INC17:%.*]], label [[CLEANUP20:%.*]]
+; CHECK-NEXT:    [[CLEANUP_DEST15:%.*]] = phi i32 [ 0, [[FOR_END13]] ], [ [[CLEANUP_DEST]], [[CLEANUP]] ], [ 1, [[FOR_BODY4]] ]
+; CHECK-NEXT:    [[COND1:%.*]] = icmp eq i32 [[CLEANUP_DEST15]], 0
+; CHECK-NEXT:    br i1 [[COND1]], label [[FOR_INC17]], label [[CLEANUP20:%.*]]
 ; CHECK:       for.inc17:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
+; CHECK-NEXT:    [[INC18]] = add nsw i32 [[TMP0]], 1
 ; CHECK-NEXT:    br label [[FOR_COND1]]
 ; CHECK:       for.end19:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[CLEANUP20]]
 ; CHECK:       cleanup20:
-; CHECK-NEXT:    br i1 false, label [[FOR_COND]], label [[CLEANUP23:%.*]]
+; CHECK-NEXT:    [[PHIOFOPS:%.*]] = phi i1 [ true, [[FOR_BODY_FOR_COND4_CRIT_EDGE]] ], [ [[COND1]], [[CLEANUP14]] ]
+; CHECK-NEXT:    [[CLEANUP_DEST21:%.*]] = phi i32 [ [[CLEANUP_DEST15]], [[CLEANUP14]] ], [ 0, [[FOR_BODY_FOR_COND4_CRIT_EDGE]] ]
+; CHECK-NEXT:    br i1 [[PHIOFOPS]], label [[FOR_COND]], label [[CLEANUP23:%.*]]
 ; CHECK:       cleanup23:
 ; CHECK-NEXT:    ret void
 ;
@@ -78,7 +82,7 @@ for.body3:                                        ; preds = %for.body
   br label %cleanup14
 
 for.cond4:                                        ; preds = %cleanup, %for.body.for.cond4_crit_edge
-  br i1 %arg, label %if.then, label %if.end
+  br i1 %arg2, label %if.then, label %if.end
 
 if.then:                                          ; preds = %for.cond4
   br label %cleanup
diff --git a/llvm/test/Transforms/NewGVN/pr43441.ll b/llvm/test/Transforms/NewGVN/pr43441.ll
index 77c91754e7f96d..babe09340ea29a 100644
--- a/llvm/test/Transforms/NewGVN/pr43441.ll
+++ b/llvm/test/Transforms/NewGVN/pr43441.ll
@@ -4,35 +4,31 @@
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-define dso_local void @print_long_format(i32 %arg) #0 {
+define dso_local void @print_long_format(i32 %arg, i1 %arg2) #0 {
 ; CHECK-LABEL: define dso_local void @print_long_format(
-; CHECK-SAME: i32 [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: i32 [[ARG:%.*]], i1 [[ARG2:%.*]]) #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    switch i32 0, label [[SW_DEFAULT:%.*]] [
+; CHECK-NEXT:    switch i32 [[ARG]], label [[SW_DEFAULT:%.*]] [
 ; CHECK-NEXT:      i32 1, label [[SW_BB:%.*]]
 ; CHECK-NEXT:      i32 0, label [[SW_BB19:%.*]]
 ; CHECK-NEXT:      i32 2, label [[SW_BB23:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       sw.bb:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       sw.bb19:
-; CHECK-NEXT:    br i1 false, label [[IF_THEN37:%.*]], label [[IF_END50:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[IF_THEN37:%.*]], label [[IF_END50:%.*]]
 ; CHECK:       sw.bb23:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       sw.default:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.then37:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end50:
 ; CHECK-NEXT:    [[CALL180:%.*]] = call i32 @timespec_cmp() #[[ATTR2:[0-9]+]]
 ; CHECK-NEXT:    ret void
 ;
 entry:
-  switch i32 0, label %sw.default [
+  switch i32 %arg, label %sw.default [
   i32 1, label %sw.bb
   i32 0, label %sw.bb19
   i32 2, label %sw.bb23
@@ -42,7 +38,7 @@ sw.bb:                                            ; preds = %entry
   unreachable
 
 sw.bb19:                                          ; preds = %entry
-  br i1 false, label %if.then37, label %if.end50
+  br i1 %arg2, label %if.then37, label %if.end50
 
 sw.bb23:                                          ; preds = %entry
   unreachable

>From 66e0394309765afb1c1389b954dca6d2b330198d Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Mon, 25 Nov 2024 22:22:35 -0700
Subject: [PATCH 5/7] Revert changes for br i1 undef

Revert changes until clarifying why update_test_check generates
br i1 false even if we replaced undef with %arg2.
---
 llvm/test/Transforms/NewGVN/stale-loop-info.ll | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/test/Transforms/NewGVN/stale-loop-info.ll b/llvm/test/Transforms/NewGVN/stale-loop-info.ll
index 80724035adff1c..7abe80b005ecf2 100644
--- a/llvm/test/Transforms/NewGVN/stale-loop-info.ll
+++ b/llvm/test/Transforms/NewGVN/stale-loop-info.ll
@@ -25,15 +25,14 @@ define hidden zeroext i1 @eggs(ptr %arg, i1 %arg2) unnamed_addr align 2 {
 ; CHECK:       bb6:
 ; CHECK-NEXT:    br label [[BB7:%.*]]
 ; CHECK:       bb7:
-; CHECK-NEXT:    br i1 false, label [[BB11:%.*]], label [[BB8:%.*]]
+; CHECK-NEXT:    br i1 undef, label [[BB11:%.*]], label [[BB8:%.*]]
 ; CHECK:       bb8:
 ; CHECK-NEXT:    [[TMP9:%.*]] = load ptr, ptr [[TMP]], align 8
 ; CHECK-NEXT:    br label [[BB12:%.*]]
 ; CHECK:       bb11:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    br label [[BB12]]
 ; CHECK:       bb12:
-; CHECK-NEXT:    [[TMP13:%.*]] = phi ptr [ poison, [[BB11]] ], [ [[TMP9]], [[BB8]] ]
+; CHECK-NEXT:    [[TMP13:%.*]] = phi ptr [ [[TMP]], [[BB11]] ], [ [[TMP9]], [[BB8]] ]
 ; CHECK-NEXT:    call void @snork.1(ptr [[TMP13]]) #[[ATTR1:[0-9]+]]
 ; CHECK-NEXT:    br label [[BB6]]
 ; CHECK:       bb14:
@@ -50,7 +49,7 @@ bb6:                                              ; preds = %bb12, %bb3
   br label %bb7
 
 bb7:                                              ; preds = %bb6
-  br i1 %arg2, label %bb11, label %bb8
+  br i1 undef, label %bb11, label %bb8
 
 bb8:                                              ; preds = %bb7
   %tmp9 = load ptr, ptr %tmp, align 8

>From a50b08a6db637e0f90e79696e1dc60913de9877e Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Mon, 25 Nov 2024 23:53:37 -0700
Subject: [PATCH 6/7] Replace undef with different arguments

---
 llvm/test/Transforms/NewGVN/pr25440.ll | 28 +++++++++++++-------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/llvm/test/Transforms/NewGVN/pr25440.ll b/llvm/test/Transforms/NewGVN/pr25440.ll
index 2cba2d8260fa4c..2d74b2e06640e0 100644
--- a/llvm/test/Transforms/NewGVN/pr25440.ll
+++ b/llvm/test/Transforms/NewGVN/pr25440.ll
@@ -10,38 +10,38 @@ target triple = "thumbv7--linux-gnueabi"
 @length = external global [0 x i32], align 4
 
 ; Function Attrs: nounwind
-define fastcc void @foo(ptr nocapture readonly %x, i1 %arg, i1 %arg2) {
+define fastcc void @foo(ptr nocapture readonly %x, i1 %arg, i1 %arg2, i1 %arg3, i1 %arg4) {
 ; CHECK-LABEL: define fastcc void @foo(
-; CHECK-SAME: ptr nocapture readonly [[X:%.*]], i1 [[ARG:%.*]], i1 [[ARG2:%.*]]) {
+; CHECK-SAME: ptr nocapture readonly [[X:%.*]], i1 [[ARG:%.*]], i1 [[ARG2:%.*]], i1 [[ARG3:%.*]], i1 [[ARG4:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[BB0:%.*]]
 ; CHECK:       bb0:
-; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[X]], align 4
+; CHECK-NEXT:    [[X_TR:%.*]] = phi ptr [ [[X]], [[ENTRY:%.*]] ], [ null, [[LAND_LHS_TRUE:%.*]] ]
+; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[X_TR]], align 4
 ; CHECK-NEXT:    [[CONV:%.*]] = zext i16 [[TMP0]] to i32
 ; CHECK-NEXT:    switch i32 [[CONV]], label [[IF_END_50:%.*]] [
 ; CHECK-NEXT:      i32 43, label [[CLEANUP:%.*]]
 ; CHECK-NEXT:      i32 52, label [[IF_THEN_5:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       if.then.5:
-; CHECK-NEXT:    br i1 [[ARG]], label [[LAND_LHS_TRUE:%.*]], label [[IF_THEN_26:%.*]]
+; CHECK-NEXT:    br i1 [[ARG]], label [[LAND_LHS_TRUE]], label [[IF_THEN_26:%.*]]
 ; CHECK:       land.lhs.true:
-; CHECK-NEXT:    br i1 true, label [[CLEANUP]], label [[BB0]]
+; CHECK-NEXT:    br i1 [[ARG2]], label [[CLEANUP]], label [[BB0]]
 ; CHECK:       if.then.26:
-; CHECK-NEXT:    br i1 false, label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
 ; CHECK:       cond.false:
-; CHECK-NEXT:    [[MODE:%.*]] = getelementptr inbounds [[STRUCT_A:%.*]], ptr [[X]], i32 0, i32 1
+; CHECK-NEXT:    [[MODE:%.*]] = getelementptr inbounds [[STRUCT_A:%.*]], ptr [[X_TR]], i32 0, i32 1
 ; CHECK-NEXT:    [[BF_LOAD:%.*]] = load i16, ptr [[MODE]], align 2
 ; CHECK-NEXT:    br label [[COND_END]]
 ; CHECK:       cond.end:
-; CHECK-NEXT:    br i1 [[ARG2]], label [[IF_THEN_44:%.*]], label [[CLEANUP]]
+; CHECK-NEXT:    br i1 [[ARG3]], label [[IF_THEN_44:%.*]], label [[CLEANUP]]
 ; CHECK:       if.then.44:
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end.50:
 ; CHECK-NEXT:    [[ARRAYIDX52:%.*]] = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 [[CONV]]
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX52]], align 4
-; CHECK-NEXT:    br i1 false, label [[FOR_BODY_57:%.*]], label [[CLEANUP]]
+; CHECK-NEXT:    br i1 [[ARG4]], label [[FOR_BODY_57:%.*]], label [[CLEANUP]]
 ; CHECK:       for.body.57:
-; CHECK-NEXT:    store i8 poison, ptr null, align 1
 ; CHECK-NEXT:    unreachable
 ; CHECK:       cleanup:
 ; CHECK-NEXT:    ret void
@@ -62,11 +62,11 @@ if.then.5:                                        ; preds = %bb0
   br i1 %arg, label %land.lhs.true, label %if.then.26
 
 land.lhs.true:                                    ; preds = %if.then.5
-  br i1 true, label %cleanup, label %bb0
+  br i1 %arg2, label %cleanup, label %bb0
 
 if.then.26:                                       ; preds = %if.then.5
   %x.tr.lcssa163 = phi ptr [ %x.tr, %if.then.5 ]
-  br i1 %arg, label %cond.end, label %cond.false
+  br i1 %arg3, label %cond.end, label %cond.false
 
 cond.false:                                       ; preds = %if.then.26
   %mode = getelementptr inbounds %struct.a, ptr %x.tr.lcssa163, i32 0, i32 1
@@ -75,7 +75,7 @@ cond.false:                                       ; preds = %if.then.26
   br label %cond.end
 
 cond.end:                                         ; preds = %cond.false, %if.then.26
-  br i1 %arg2, label %if.then.44, label %cleanup
+  br i1 %arg3, label %if.then.44, label %cleanup
 
 if.then.44:                                       ; preds = %cond.end
   unreachable
@@ -84,7 +84,7 @@ if.end.50:                                        ; preds = %bb0
   %conv.lcssa = phi i32 [ %conv, %bb0 ]
   %arrayidx52 = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 %conv.lcssa
   %1 = load i32, ptr %arrayidx52, align 4
-  br i1 false, label %for.body.57, label %cleanup
+  br i1 %arg4, label %for.body.57, label %cleanup
 
 for.body.57:                                      ; preds = %if.end.50
   %i.2157 = add nsw i32 %1, -1

>From 80886911a2d89141e68947c9a742e1ca6a3b23ce Mon Sep 17 00:00:00 2001
From: Lee <lee10202013 at gmail.com>
Date: Tue, 26 Nov 2024 10:36:33 -0700
Subject: [PATCH 7/7] Replace true with different arguments

---
 .../Transforms/NewGVN/eliminate-ssacopy.ll    | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
index 83992c5ba5bcda..610a254a52568c 100644
--- a/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
+++ b/llvm/test/Transforms/NewGVN/eliminate-ssacopy.ll
@@ -9,7 +9,7 @@
 @a = external dso_local local_unnamed_addr global i8, align 1
 @f = external dso_local local_unnamed_addr global i16, align 2
 
-define void @g(i1 %arg) {
+define void @g(i1 %arg, i1 %arg2, i1 %arg3) {
 ; CHECK-LABEL: @g(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[FOR_COND1THREAD_PRE_SPLIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
@@ -18,21 +18,24 @@ define void @g(i1 %arg) {
 ; CHECK:       for.cond1thread-pre-split:
 ; CHECK-NEXT:    br label [[FOR_END4_SPLIT:%.*]]
 ; CHECK:       for.end4.split:
-; CHECK-NEXT:    br i1 true, label [[FOR_COND6_PREHEADER:%.*]], label [[IF_END11:%.*]]
+; CHECK-NEXT:    br i1 [[ARG2:%.*]], label [[FOR_COND6_PREHEADER:%.*]], label [[IF_END11:%.*]]
 ; CHECK:       for.cond6.preheader:
-; CHECK-NEXT:    br i1 true, label [[FOR_COND6_PREHEADER3:%.*]], label [[IF_END11_LOOPEXIT:%.*]]
+; CHECK-NEXT:    br i1 [[ARG3:%.*]], label [[FOR_COND6_PREHEADER3:%.*]], label [[IF_END11_LOOPEXIT:%.*]]
 ; CHECK:       for.cond6.preheader3:
 ; CHECK-NEXT:    br label [[IF_END11_LOOPEXIT]]
 ; CHECK:       if.end11.loopexit:
-; CHECK-NEXT:    store i32 1, ptr @b, align 4
+; CHECK-NEXT:    [[STOREMERGE_LCSSA:%.*]] = phi i32 [ 0, [[FOR_COND6_PREHEADER]] ], [ 1, [[FOR_COND6_PREHEADER3]] ]
+; CHECK-NEXT:    store i32 [[STOREMERGE_LCSSA]], ptr @b, align 4
 ; CHECK-NEXT:    br label [[IF_END11]]
 ; CHECK:       if.end11:
+; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @b, align 4
 ; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr @a, align 1
 ; CHECK-NEXT:    [[CONV:%.*]] = sext i8 [[TMP1]] to i32
-; CHECK-NEXT:    [[CMP12:%.*]] = icmp eq i32 1, [[CONV]]
+; CHECK-NEXT:    [[CMP12:%.*]] = icmp eq i32 [[TMP0]], [[CONV]]
 ; CHECK-NEXT:    br i1 [[CMP12]], label [[IF_THEN14:%.*]], label [[IF_END16:%.*]]
 ; CHECK:       if.then14:
-; CHECK-NEXT:    store i16 1, ptr @f, align 2
+; CHECK-NEXT:    [[CONV15:%.*]] = trunc i32 [[TMP0]] to i16
+; CHECK-NEXT:    store i16 [[CONV15]], ptr @f, align 2
 ; CHECK-NEXT:    unreachable
 ; CHECK:       if.end16:
 ; CHECK-NEXT:    ret void
@@ -47,10 +50,10 @@ for.cond1thread-pre-split:                        ; preds = %entry
   br label %for.end4.split
 
 for.end4.split:                                   ; preds = %for.cond1thread-pre-split
-  br i1 true, label %for.cond6.preheader, label %if.end11
+  br i1 %arg2, label %for.cond6.preheader, label %if.end11
 
 for.cond6.preheader:                              ; preds = %for.end4.split
-  br i1 %arg, label %for.cond6.preheader3, label %if.end11.loopexit
+  br i1 %arg3, label %for.cond6.preheader3, label %if.end11.loopexit
 
 for.cond6.preheader3:                             ; preds = %for.cond6.preheader
   br label %if.end11.loopexit



More information about the llvm-commits mailing list