[llvm] [InstCombine] Replace all dominated uses of condition with constants (PR #105510)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 23:39:12 PDT 2024
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/105510
>From c4d686ceaa9736449c9f9fde4f096875518512c9 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Sat, 31 Aug 2024 13:34:07 +0800
Subject: [PATCH 1/3] [InstCombine] Use an independent cond for the second
branch. NFC.
---
.../phi-known-bits-operand-order.ll | 12 ++++++----
llvm/test/Transforms/InstCombine/zext-phi.ll | 24 ++++++++++---------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/llvm/test/Transforms/InstCombine/phi-known-bits-operand-order.ll b/llvm/test/Transforms/InstCombine/phi-known-bits-operand-order.ll
index a9ebcf629a4029..6a054688753500 100644
--- a/llvm/test/Transforms/InstCombine/phi-known-bits-operand-order.ll
+++ b/llvm/test/Transforms/InstCombine/phi-known-bits-operand-order.ll
@@ -16,7 +16,8 @@ define void @phi_recurrence_start_first() {
; CHECK-NEXT: br i1 [[COND_V]], label [[IF_THEN:%.*]], label [[WHILE_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: [[START]] = add nuw nsw i32 [[CELL_0]], 1
-; CHECK-NEXT: br i1 [[COND_V]], label [[FOR_COND11:%.*]], label [[FOR_COND26]]
+; CHECK-NEXT: [[COND_V2:%.*]] = call i1 @cond()
+; CHECK-NEXT: br i1 [[COND_V2]], label [[FOR_COND11:%.*]], label [[FOR_COND26]]
; CHECK: for.cond11:
; CHECK-NEXT: [[I_1:%.*]] = phi i32 [ [[START]], [[IF_THEN]] ], [ [[STEP:%.*]], [[FOR_COND11]] ]
; CHECK-NEXT: [[CMP13:%.*]] = icmp ult i32 [[I_1]], 100
@@ -37,7 +38,8 @@ while.cond: ; preds = %entry, %for.cond26
if.then: ; preds = %while.cond
%start = add nsw i32 %cell.0, 1
- br i1 %cond.v, label %for.cond11, label %for.cond26
+ %cond.v2 = call i1 @cond()
+ br i1 %cond.v2, label %for.cond11, label %for.cond26
for.cond11: ; preds = %for.cond11, %if.then
%i.1 = phi i32 [ %start, %if.then ], [ %step, %for.cond11 ]
@@ -62,7 +64,8 @@ define void @phi_recurrence_step_first() {
; CHECK-NEXT: br i1 [[COND_V]], label [[IF_THEN:%.*]], label [[WHILE_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: [[START]] = add nuw nsw i32 [[CELL_0]], 1
-; CHECK-NEXT: br i1 [[COND_V]], label [[FOR_COND11:%.*]], label [[FOR_COND26]]
+; CHECK-NEXT: [[COND_V2:%.*]] = call i1 @cond()
+; CHECK-NEXT: br i1 [[COND_V2]], label [[FOR_COND11:%.*]], label [[FOR_COND26]]
; CHECK: for.cond11:
; CHECK-NEXT: [[I_1:%.*]] = phi i32 [ [[STEP:%.*]], [[FOR_COND11]] ], [ [[START]], [[IF_THEN]] ]
; CHECK-NEXT: [[CMP13:%.*]] = icmp ult i32 [[I_1]], 100
@@ -83,7 +86,8 @@ while.cond: ; preds = %entry, %for.cond26
if.then: ; preds = %while.cond
%start = add nsw i32 %cell.0, 1
- br i1 %cond.v, label %for.cond11, label %for.cond26
+ %cond.v2 = call i1 @cond()
+ br i1 %cond.v2, label %for.cond11, label %for.cond26
for.cond11: ; preds = %for.cond11, %if.then
%i.1 = phi i32 [ %step, %for.cond11 ], [ %start, %if.then]
diff --git a/llvm/test/Transforms/InstCombine/zext-phi.ll b/llvm/test/Transforms/InstCombine/zext-phi.ll
index 5a403eb1c1175e..a50e11c57c36ec 100644
--- a/llvm/test/Transforms/InstCombine/zext-phi.ll
+++ b/llvm/test/Transforms/InstCombine/zext-phi.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
target datalayout = "e-m:e-i64:64-n8:16:32:64"
@@ -6,20 +7,21 @@ target datalayout = "e-m:e-i64:64-n8:16:32:64"
; as a legal type because it is a fundamental type in IR.
; This means we should shrink the phi (sink the zexts).
-define i64 @sink_i1_casts(i1 %cond1, i1 %cond2) {
-; CHECK-LABEL: @sink_i1_casts(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: br i1 %cond1, label %if, label %end
-; CHECK: if:
-; CHECK-NEXT: br label %end
-; CHECK: end:
-; CHECK-NEXT: [[PHI_IN:%.*]] = phi i1 [ %cond1, %entry ], [ %cond2, %if ]
-; CHECK-NEXT: [[PHI:%.*]] = zext i1 [[PHI_IN]] to i64
-; CHECK-NEXT: ret i64 [[PHI]]
+define i64 @sink_i1_casts(i1 %cond1, i1 %cond2, i1 %cond) {
+; CHECK-LABEL: define i64 @sink_i1_casts(
+; CHECK-SAME: i1 [[COND1:%.*]], i1 [[COND2:%.*]], i1 [[COND:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT: br i1 [[COND]], label %[[IF:.*]], label %[[END:.*]]
+; CHECK: [[IF]]:
+; CHECK-NEXT: br label %[[END]]
+; CHECK: [[END]]:
+; CHECK-NEXT: [[PHI_IN1:%.*]] = phi i1 [ [[COND1]], %[[ENTRY]] ], [ [[COND2]], %[[IF]] ]
+; CHECK-NEXT: [[PHI_IN:%.*]] = zext i1 [[PHI_IN1]] to i64
+; CHECK-NEXT: ret i64 [[PHI_IN]]
;
entry:
%z1 = zext i1 %cond1 to i64
- br i1 %cond1, label %if, label %end
+ br i1 %cond, label %if, label %end
if:
%z2 = zext i1 %cond2 to i64
>From 9f69dd688355abfe9d022a5fb269bdb9a7cf7e33 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Sat, 31 Aug 2024 14:32:40 +0800
Subject: [PATCH 2/3] [InstCombine] Add pre-commit tests. NFC.
---
llvm/test/Transforms/InstCombine/branch.ll | 99 +++++++++++++++++++
.../PhaseOrdering/branch-dom-cond.ll | 50 ++++++++++
2 files changed, 149 insertions(+)
create mode 100644 llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
diff --git a/llvm/test/Transforms/InstCombine/branch.ll b/llvm/test/Transforms/InstCombine/branch.ll
index 1110d5f90b1790..fdb15d3af8f4dd 100644
--- a/llvm/test/Transforms/InstCombine/branch.ll
+++ b/llvm/test/Transforms/InstCombine/branch.ll
@@ -242,3 +242,102 @@ t:
f:
ret i32 3
}
+
+define i32 @dom_true(i1 %cmp) {
+; CHECK-LABEL: @dom_true(
+; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT: ret i32 [[ZEXT]]
+; CHECK: if.else:
+; CHECK-NEXT: ret i32 0
+;
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ %zext = zext i1 %cmp to i32
+ ret i32 %zext
+
+if.else:
+ ret i32 0
+}
+
+define i32 @dom_false(i1 %cmp) {
+; CHECK-LABEL: @dom_false(
+; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT: ret i32 [[ZEXT]]
+; CHECK: if.else:
+; CHECK-NEXT: ret i32 0
+;
+ br i1 %cmp, label %if.else, label %if.then
+
+if.then:
+ %zext = zext i1 %cmp to i32
+ ret i32 %zext
+
+if.else:
+ ret i32 0
+}
+
+define i32 @dom_true_phi(i1 %cmp) {
+; CHECK-LABEL: @dom_true_phi(
+; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: [[PHI:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ [[CMP]], [[IF_ELSE]] ]
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[PHI]] to i32
+; CHECK-NEXT: ret i32 [[ZEXT]]
+;
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ br label %if.end
+
+if.else:
+ br label %if.end
+
+if.end:
+ %phi = phi i1 [ true, %if.then ], [ %cmp, %if.else ]
+ %zext = zext i1 %phi to i32
+ ret i32 %zext
+}
+
+; Negative tests
+
+define i32 @same_dest(i1 %cmp) {
+; CHECK-LABEL: @same_dest(
+; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_THEN]]
+; CHECK: if.then:
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP:%.*]] to i32
+; CHECK-NEXT: ret i32 [[ZEXT]]
+;
+ br i1 %cmp, label %if.then, label %if.then
+
+if.then:
+ %zext = zext i1 %cmp to i32
+ ret i32 %zext
+}
+
+define i32 @not_dom(i1 %cmp) {
+; CHECK-LABEL: @not_dom(
+; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: br label [[IF_ELSE]]
+; CHECK: if.else:
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT: ret i32 [[ZEXT]]
+;
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ br label %if.else
+
+if.else:
+ %zext = zext i1 %cmp to i32
+ ret i32 %zext
+}
diff --git a/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll b/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
new file mode 100644
index 00000000000000..80ccbc7378905a
--- /dev/null
+++ b/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
@@ -0,0 +1,50 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -O3 -S < %s | FileCheck %s
+; RUN: opt -passes='default<O3>' -S < %s | FileCheck %s
+
+define void @growTables(ptr %p) {
+; CHECK-LABEL: define void @growTables(
+; CHECK-SAME: ptr [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*]]:
+; CHECK-NEXT: [[CALL:%.*]] = load volatile i32, ptr [[P]], align 4
+; CHECK-NEXT: [[CMP71:%.*]] = icmp sgt i32 [[CALL]], 0
+; CHECK-NEXT: br i1 [[CMP71]], label %[[FOR_BODY:.*]], label %[[COMMON_RET:.*]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT: [[I_02:%.*]] = phi i32 [ [[INC:%.*]], %[[FOR_BODY]] ], [ 0, %[[ENTRY]] ]
+; CHECK-NEXT: [[CALL9:%.*]] = load volatile ptr, ptr [[P]], align 8
+; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_02]], 1
+; CHECK-NEXT: [[CMP7:%.*]] = icmp slt i32 [[INC]], [[CALL]]
+; CHECK-NEXT: br i1 [[CMP7]], label %[[FOR_BODY]], label %[[FOR_END:.*]]
+; CHECK: [[FOR_END]]:
+; CHECK-NEXT: br i1 [[CMP71]], label %[[FOR_BODY12:.*]], label %[[COMMON_RET]]
+; CHECK: [[FOR_BODY12]]:
+; CHECK-NEXT: [[CALL14:%.*]] = load volatile ptr, ptr [[P]], align 8
+; CHECK-NEXT: br label %[[COMMON_RET]]
+; CHECK: [[COMMON_RET]]:
+; CHECK-NEXT: ret void
+;
+entry:
+ %call = load volatile i32, ptr %p, align 4
+ br label %for.cond
+
+for.cond:
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %cmp7 = icmp slt i32 %i.0, %call
+ br i1 %cmp7, label %for.body, label %for.end
+
+for.body:
+ %call9 = load volatile ptr, ptr %p, align 8
+ %inc = add i32 %i.0, 1
+ br label %for.cond
+
+for.end:
+ %cmp11 = icmp sgt i32 %call, 0
+ br i1 %cmp11, label %for.body12, label %common.ret
+
+for.body12:
+ %call14 = load volatile ptr, ptr %p, align 8
+ br label %common.ret
+
+common.ret:
+ ret void
+}
>From b0b538a6af43f2a5afab918828a0be4e91acf913 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Sat, 31 Aug 2024 14:38:00 +0800
Subject: [PATCH 3/3] [InstCombine] Replace all dominated uses of condition
with constants
---
.../InstCombine/InstructionCombining.cpp | 17 ++++++++++
llvm/test/Transforms/InstCombine/assume.ll | 6 ++--
llvm/test/Transforms/InstCombine/branch.ll | 9 ++----
.../InstCombine/compare-unescaped.ll | 2 +-
llvm/test/Transforms/InstCombine/icmp-dom.ll | 20 ++++++------
.../InstCombine/indexed-gep-compares.ll | 2 +-
.../test/Transforms/InstCombine/known-bits.ll | 6 ++--
llvm/test/Transforms/InstCombine/phi.ll | 16 +++++-----
llvm/test/Transforms/InstCombine/pr44245.ll | 32 ++++++-------------
.../Transforms/InstCombine/sink-into-ncd.ll | 4 +--
.../InstCombine/sink_to_unreachable.ll | 10 +++---
.../AArch64/uniform-args-call-variants.ll | 4 +--
.../constraint-elimination-placement.ll | 14 ++++----
.../PhaseOrdering/branch-dom-cond.ll | 4 +--
14 files changed, 71 insertions(+), 75 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 8a96d1d0fb4c90..866e5f8a00b52d 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3705,6 +3705,23 @@ Instruction *InstCombinerImpl::visitBranchInst(BranchInst &BI) {
return nullptr;
}
+ // Replace all dominated uses of the condition with true/false
+ if (BI.getSuccessor(0) != BI.getSuccessor(1)) {
+ for (auto &U : make_early_inc_range(Cond->uses())) {
+ BasicBlockEdge Edge0(BI.getParent(), BI.getSuccessor(0));
+ if (DT.dominates(Edge0, U)) {
+ replaceUse(U, ConstantInt::getTrue(Cond->getType()));
+ addToWorklist(cast<Instruction>(U.getUser()));
+ continue;
+ }
+ BasicBlockEdge Edge1(BI.getParent(), BI.getSuccessor(1));
+ if (DT.dominates(Edge1, U)) {
+ replaceUse(U, ConstantInt::getFalse(Cond->getType()));
+ addToWorklist(cast<Instruction>(U.getUser()));
+ }
+ }
+ }
+
DC.registerBranch(&BI);
return nullptr;
}
diff --git a/llvm/test/Transforms/InstCombine/assume.ll b/llvm/test/Transforms/InstCombine/assume.ll
index 474da9968b66ad..a728c294628cad 100644
--- a/llvm/test/Transforms/InstCombine/assume.ll
+++ b/llvm/test/Transforms/InstCombine/assume.ll
@@ -485,7 +485,7 @@ define i1 @nonnull3B(ptr %a, i1 %control) {
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) [ "nonnull"(ptr [[LOAD]]) ]
; CHECK-NEXT: ret i1 [[CMP]]
; CHECK: not_taken:
-; CHECK-NEXT: ret i1 [[CONTROL]]
+; CHECK-NEXT: ret i1 false
;
entry:
%load = load ptr, ptr %a
@@ -513,7 +513,7 @@ define i1 @nonnull3C(ptr %a, i1 %control) {
; CHECK: exit:
; CHECK-NEXT: ret i1 [[CMP2]]
; CHECK: not_taken:
-; CHECK-NEXT: ret i1 [[CONTROL]]
+; CHECK-NEXT: ret i1 false
;
entry:
%load = load ptr, ptr %a
@@ -543,7 +543,7 @@ define i1 @nonnull3D(ptr %a, i1 %control) {
; CHECK: exit:
; CHECK-NEXT: ret i1 [[CMP2]]
; CHECK: not_taken:
-; CHECK-NEXT: ret i1 [[CONTROL]]
+; CHECK-NEXT: ret i1 false
;
entry:
%load = load ptr, ptr %a
diff --git a/llvm/test/Transforms/InstCombine/branch.ll b/llvm/test/Transforms/InstCombine/branch.ll
index fdb15d3af8f4dd..1d5ff72eef9ce6 100644
--- a/llvm/test/Transforms/InstCombine/branch.ll
+++ b/llvm/test/Transforms/InstCombine/branch.ll
@@ -247,8 +247,7 @@ define i32 @dom_true(i1 %cmp) {
; CHECK-LABEL: @dom_true(
; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
-; CHECK-NEXT: ret i32 [[ZEXT]]
+; CHECK-NEXT: ret i32 1
; CHECK: if.else:
; CHECK-NEXT: ret i32 0
;
@@ -266,8 +265,7 @@ define i32 @dom_false(i1 %cmp) {
; CHECK-LABEL: @dom_false(
; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
-; CHECK-NEXT: ret i32 [[ZEXT]]
+; CHECK-NEXT: ret i32 0
; CHECK: if.else:
; CHECK-NEXT: ret i32 0
;
@@ -289,8 +287,7 @@ define i32 @dom_true_phi(i1 %cmp) {
; CHECK: if.else:
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
-; CHECK-NEXT: [[PHI:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ [[CMP]], [[IF_ELSE]] ]
-; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[PHI]] to i32
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
; CHECK-NEXT: ret i32 [[ZEXT]]
;
br i1 %cmp, label %if.then, label %if.else
diff --git a/llvm/test/Transforms/InstCombine/compare-unescaped.ll b/llvm/test/Transforms/InstCombine/compare-unescaped.ll
index ab380c00f82641..02eb464c814c81 100644
--- a/llvm/test/Transforms/InstCombine/compare-unescaped.ll
+++ b/llvm/test/Transforms/InstCombine/compare-unescaped.ll
@@ -86,7 +86,7 @@ define i1 @compare_and_call_after() {
; CHECK-NEXT: call void @escape(ptr [[M]])
; CHECK-NEXT: ret i1 true
; CHECK: just_return:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 false
;
%m = call ptr @malloc(i64 24)
%lgp = load ptr, ptr @gp, align 8, !nonnull !0
diff --git a/llvm/test/Transforms/InstCombine/icmp-dom.ll b/llvm/test/Transforms/InstCombine/icmp-dom.ll
index 83cedd5ea9cb45..3cf3a7af77041c 100644
--- a/llvm/test/Transforms/InstCombine/icmp-dom.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-dom.ll
@@ -196,7 +196,7 @@ define i1 @trueblock_cmp_is_false(i32 %x, i32 %y) {
; CHECK: t:
; CHECK-NEXT: ret i1 false
; CHECK: f:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 false
;
entry:
%cmp = icmp sgt i32 %x, %y
@@ -216,7 +216,7 @@ define i1 @trueblock_cmp_is_false_commute(i32 %x, i32 %y) {
; CHECK: t:
; CHECK-NEXT: ret i1 false
; CHECK: f:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 false
;
entry:
%cmp = icmp eq i32 %x, %y
@@ -236,7 +236,7 @@ define i1 @trueblock_cmp_is_true(i32 %x, i32 %y) {
; CHECK: t:
; CHECK-NEXT: ret i1 true
; CHECK: f:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 false
;
entry:
%cmp = icmp ult i32 %x, %y
@@ -256,7 +256,7 @@ define i1 @trueblock_cmp_is_true_commute(i32 %x, i32 %y) {
; CHECK: t:
; CHECK-NEXT: ret i1 true
; CHECK: f:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 false
;
entry:
%cmp = icmp ugt i32 %x, %y
@@ -271,10 +271,10 @@ f:
define i1 @falseblock_cmp_is_false(i32 %x, i32 %y) {
; CHECK-LABEL: @falseblock_cmp_is_false(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
+; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP_NOT]], label [[F:%.*]], label [[T:%.*]]
; CHECK: t:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
; CHECK: f:
; CHECK-NEXT: ret i1 false
;
@@ -294,7 +294,7 @@ define i1 @falseblock_cmp_is_false_commute(i32 %x, i32 %y) {
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
; CHECK: t:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
; CHECK: f:
; CHECK-NEXT: ret i1 false
;
@@ -314,7 +314,7 @@ define i1 @falseblock_cmp_is_true(i32 %x, i32 %y) {
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
; CHECK: t:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
; CHECK: f:
; CHECK-NEXT: ret i1 true
;
@@ -334,7 +334,7 @@ define i1 @falseblock_cmp_is_true_commute(i32 %x, i32 %y) {
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
; CHECK: t:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
; CHECK: f:
; CHECK-NEXT: ret i1 true
;
diff --git a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
index 2b5b3fce705354..ef8f5fea4ff7c1 100644
--- a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
+++ b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
@@ -292,7 +292,7 @@ define i1 @test7() {
; CHECK-NEXT: [[CMP:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ true, [[BB7]] ]
; CHECK-NEXT: br i1 [[CMP]], label [[BB10:%.*]], label [[BB7]]
; CHECK: bb10:
-; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK-NEXT: ret i1 true
;
entry:
br label %bb7
diff --git a/llvm/test/Transforms/InstCombine/known-bits.ll b/llvm/test/Transforms/InstCombine/known-bits.ll
index 3482a8e9759929..8cfb987e422f38 100644
--- a/llvm/test/Transforms/InstCombine/known-bits.ll
+++ b/llvm/test/Transforms/InstCombine/known-bits.ll
@@ -1664,11 +1664,9 @@ define i64 @pr92084(double %x) {
; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+00
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then1:
-; CHECK-NEXT: br i1 [[CMP]], label [[IF_ELSE]], label [[IF_THEN2:%.*]]
+; CHECK-NEXT: br i1 true, label [[IF_ELSE]], label [[IF_THEN2:%.*]]
; CHECK: if.then2:
-; CHECK-NEXT: [[CAST:%.*]] = bitcast double [[X]] to i64
-; CHECK-NEXT: [[AND:%.*]] = and i64 [[CAST]], 1
-; CHECK-NEXT: ret i64 [[AND]]
+; CHECK-NEXT: ret i64 poison
; CHECK: if.else:
; CHECK-NEXT: ret i64 0
;
diff --git a/llvm/test/Transforms/InstCombine/phi.ll b/llvm/test/Transforms/InstCombine/phi.ll
index 673c8f6c9488d6..ba29f4290a9fa4 100644
--- a/llvm/test/Transforms/InstCombine/phi.ll
+++ b/llvm/test/Transforms/InstCombine/phi.ll
@@ -1543,7 +1543,7 @@ define i1 @phi_knownnonzero_eq_multiuse_oricmp(i32 %n, i32 %s, ptr %P, i32 %val)
; CHECK-NEXT: [[BOOL2:%.*]] = icmp eq i32 [[PHI]], 0
; CHECK-NEXT: br label [[CLEANUP]]
; CHECK: cleanup:
-; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ [[CMP1]], [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
+; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ false, [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
; CHECK-NEXT: ret i1 [[FINAL]]
;
entry:
@@ -1581,13 +1581,13 @@ define i1 @phi_knownnonzero_ne_multiuse_oricmp_commuted(i32 %n, i32 %s, ptr %P,
; CHECK: if.end:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 1, [[IF_THEN]] ], [ [[N]], [[ENTRY:%.*]] ]
; CHECK-NEXT: [[ORPHI:%.*]] = or i32 [[VAL:%.*]], [[PHI]]
-; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[ORPHI]], 0
-; CHECK-NEXT: br i1 [[CMP1]], label [[NEXT:%.*]], label [[CLEANUP:%.*]]
+; CHECK-NEXT: [[CMP1_NOT:%.*]] = icmp eq i32 [[ORPHI]], 0
+; CHECK-NEXT: br i1 [[CMP1_NOT]], label [[CLEANUP:%.*]], label [[NEXT:%.*]]
; CHECK: next:
; CHECK-NEXT: [[BOOL2:%.*]] = icmp ne i32 [[PHI]], 0
; CHECK-NEXT: br label [[CLEANUP]]
; CHECK: cleanup:
-; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ [[CMP1]], [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
+; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ false, [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
; CHECK-NEXT: ret i1 [[FINAL]]
;
entry:
@@ -1634,7 +1634,7 @@ define i1 @phi_knownnonzero_eq_multiuse_andicmp(i32 %n, i32 %s, ptr %P, i32 %val
; CHECK-NEXT: [[BOOL2:%.*]] = icmp eq i32 [[PHI]], 0
; CHECK-NEXT: br label [[CLEANUP]]
; CHECK: cleanup:
-; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ [[CMP1]], [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
+; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ false, [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
; CHECK-NEXT: ret i1 [[FINAL]]
;
entry:
@@ -1675,13 +1675,13 @@ define i1 @phi_knownnonzero_ne_multiuse_andicmp(i32 %n, i32 %s, ptr %P, i32 %val
; CHECK: if.end:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[SEL]], [[IF_THEN]] ], [ [[N]], [[ENTRY:%.*]] ]
; CHECK-NEXT: [[ANDPHI:%.*]] = and i32 [[PHI]], [[VAL:%.*]]
-; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[ANDPHI]], 0
-; CHECK-NEXT: br i1 [[CMP1]], label [[NEXT:%.*]], label [[CLEANUP:%.*]]
+; CHECK-NEXT: [[CMP1_NOT:%.*]] = icmp eq i32 [[ANDPHI]], 0
+; CHECK-NEXT: br i1 [[CMP1_NOT]], label [[CLEANUP:%.*]], label [[NEXT:%.*]]
; CHECK: next:
; CHECK-NEXT: [[BOOL2:%.*]] = icmp ne i32 [[PHI]], 0
; CHECK-NEXT: br label [[CLEANUP]]
; CHECK: cleanup:
-; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ [[CMP1]], [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
+; CHECK-NEXT: [[FINAL:%.*]] = phi i1 [ false, [[IF_END]] ], [ [[BOOL2]], [[NEXT]] ]
; CHECK-NEXT: ret i1 [[FINAL]]
;
entry:
diff --git a/llvm/test/Transforms/InstCombine/pr44245.ll b/llvm/test/Transforms/InstCombine/pr44245.ll
index ee5ae2edb42dae..01f209c23592f7 100644
--- a/llvm/test/Transforms/InstCombine/pr44245.ll
+++ b/llvm/test/Transforms/InstCombine/pr44245.ll
@@ -8,54 +8,42 @@ define void @test(i1 %c, ptr %p) {
; CHECK-NEXT: bb16:
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB17:%.*]], label [[BB24:%.*]]
; CHECK: bb17:
-; CHECK-NEXT: [[I:%.*]] = phi ptr [ [[DOTIN1:%.*]], [[BB47:%.*]] ], [ undef, [[BB16:%.*]] ]
-; CHECK-NEXT: store ptr [[I]], ptr [[P:%.*]], align 8
; CHECK-NEXT: ret void
; CHECK: bb24:
-; CHECK-NEXT: br i1 [[C]], label [[BB44:%.*]], label [[BB49:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB44:%.*]], label [[BB49:%.*]]
; CHECK: bb44:
-; CHECK-NEXT: [[TMP46:%.*]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
-; CHECK-NEXT: br label [[BB47]]
+; CHECK-NEXT: br label [[BB47:%.*]]
; CHECK: bb47:
-; CHECK-NEXT: [[DOTIN1]] = phi ptr [ [[DOTIN:%.*]], [[BB150:%.*]] ], [ [[TMP122:%.*]], [[BB119:%.*]] ], [ [[TMP103:%.*]], [[BB101:%.*]] ], [ [[TMP93:%.*]], [[BB91:%.*]] ], [ [[TMP83:%.*]], [[BB81:%.*]] ], [ [[TMP70:%.*]], [[BB67:%.*]] ], [ [[TMP58:%.*]], [[BB56:%.*]] ], [ [[TMP46]], [[BB44]] ]
; CHECK-NEXT: br label [[BB17]]
; CHECK: bb49:
-; CHECK-NEXT: br i1 [[C]], label [[BB56]], label [[BB59:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB56:%.*]], label [[BB59:%.*]]
; CHECK: bb56:
-; CHECK-NEXT: [[TMP58]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb59:
-; CHECK-NEXT: br i1 [[C]], label [[BB67]], label [[BB71:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB67:%.*]], label [[BB71:%.*]]
; CHECK: bb67:
-; CHECK-NEXT: [[TMP70]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb71:
-; CHECK-NEXT: br i1 [[C]], label [[BB81]], label [[BB84:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB81:%.*]], label [[BB84:%.*]]
; CHECK: bb81:
-; CHECK-NEXT: [[TMP83]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb84:
-; CHECK-NEXT: br i1 [[C]], label [[BB91]], label [[BB94:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB91:%.*]], label [[BB94:%.*]]
; CHECK: bb91:
-; CHECK-NEXT: [[TMP93]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb94:
-; CHECK-NEXT: br i1 [[C]], label [[BB101]], label [[BB104:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB101:%.*]], label [[BB104:%.*]]
; CHECK: bb101:
-; CHECK-NEXT: [[TMP103]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb104:
-; CHECK-NEXT: br i1 [[C]], label [[BB119]], label [[BB123:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB119:%.*]], label [[BB123:%.*]]
; CHECK: bb119:
-; CHECK-NEXT: [[TMP122]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb123:
-; CHECK-NEXT: br i1 [[C]], label [[BB147:%.*]], label [[BB152:%.*]]
+; CHECK-NEXT: br i1 false, label [[BB147:%.*]], label [[BB152:%.*]]
; CHECK: bb147:
-; CHECK-NEXT: [[TMP149:%.*]] = load ptr, ptr inttoptr (i64 16 to ptr), align 16
-; CHECK-NEXT: br label [[BB150]]
+; CHECK-NEXT: br label [[BB150:%.*]]
; CHECK: bb150:
-; CHECK-NEXT: [[DOTIN]] = phi ptr [ poison, [[BB152]] ], [ [[TMP149]], [[BB147]] ]
; CHECK-NEXT: br label [[BB47]]
; CHECK: bb152:
; CHECK-NEXT: store i1 true, ptr poison, align 1
diff --git a/llvm/test/Transforms/InstCombine/sink-into-ncd.ll b/llvm/test/Transforms/InstCombine/sink-into-ncd.ll
index 464cc477a503c9..5fa692d3ae7288 100644
--- a/llvm/test/Transforms/InstCombine/sink-into-ncd.ll
+++ b/llvm/test/Transforms/InstCombine/sink-into-ncd.ll
@@ -60,12 +60,12 @@ define i32 @test2(ptr %addr, i1 %c) {
; CHECK-NEXT: br label [[EXIT]]
; CHECK: right:
; CHECK-NEXT: [[Y:%.*]] = call i32 @use(ptr [[PTR]])
-; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[RIGHT_2:%.*]]
+; CHECK-NEXT: br i1 false, label [[EXIT]], label [[RIGHT_2:%.*]]
; CHECK: right.2:
; CHECK-NEXT: [[Z:%.*]] = call i32 @use(ptr [[PTR]])
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
-; CHECK-NEXT: [[P:%.*]] = phi i32 [ [[X]], [[LEFT]] ], [ [[Y]], [[RIGHT]] ], [ [[Z]], [[RIGHT_2]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[P:%.*]] = phi i32 [ [[X]], [[LEFT]] ], [ poison, [[RIGHT]] ], [ [[Z]], [[RIGHT_2]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i32 [[P]]
;
entry:
diff --git a/llvm/test/Transforms/InstCombine/sink_to_unreachable.ll b/llvm/test/Transforms/InstCombine/sink_to_unreachable.ll
index 02ed22217854ea..01510f8e9596b5 100644
--- a/llvm/test/Transforms/InstCombine/sink_to_unreachable.ll
+++ b/llvm/test/Transforms/InstCombine/sink_to_unreachable.ll
@@ -42,9 +42,8 @@ define void @test_02(i32 %x, i32 %y) {
; CHECK-NEXT: [[C3:%.*]] = icmp sgt i32 [[X]], [[Y]]
; CHECK-NEXT: br i1 [[C3]], label [[EXIT]], label [[UNREACHED:%.*]]
; CHECK: unreached:
-; CHECK-NEXT: [[C1:%.*]] = icmp eq i32 [[X]], [[Y]]
-; CHECK-NEXT: [[SIGNED:%.*]] = select i1 [[C2]], i32 -1, i32 1
-; CHECK-NEXT: [[COMPARATOR:%.*]] = select i1 [[C1]], i32 0, i32 [[SIGNED]]
+; CHECK-NEXT: [[C1:%.*]] = icmp ne i32 [[X]], [[Y]]
+; CHECK-NEXT: [[COMPARATOR:%.*]] = zext i1 [[C1]] to i32
; CHECK-NEXT: call void @use(i32 [[COMPARATOR]])
; CHECK-NEXT: unreachable
; CHECK: exit:
@@ -78,9 +77,8 @@ define i32 @test_03(i32 %x, i32 %y) {
; CHECK-NEXT: [[C3:%.*]] = icmp sgt i32 [[X]], [[Y]]
; CHECK-NEXT: br i1 [[C3]], label [[EXIT]], label [[UNREACHED:%.*]]
; CHECK: unreached:
-; CHECK-NEXT: [[C1:%.*]] = icmp eq i32 [[X]], [[Y]]
-; CHECK-NEXT: [[SIGNED:%.*]] = select i1 [[C2]], i32 -1, i32 1
-; CHECK-NEXT: [[COMPARATOR:%.*]] = select i1 [[C1]], i32 0, i32 [[SIGNED]]
+; CHECK-NEXT: [[C1:%.*]] = icmp ne i32 [[X]], [[Y]]
+; CHECK-NEXT: [[COMPARATOR:%.*]] = zext i1 [[C1]] to i32
; CHECK-NEXT: ret i32 [[COMPARATOR]]
; CHECK: exit:
; CHECK-NEXT: ret i32 0
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/uniform-args-call-variants.ll b/llvm/test/Transforms/LoopVectorize/AArch64/uniform-args-call-variants.ll
index c52227e1553756..d0decbff1a4625 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/uniform-args-call-variants.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/uniform-args-call-variants.ll
@@ -206,7 +206,7 @@ define void @test_uniform_not_invariant(ptr noalias %dst, ptr readonly %src, i64
; INTERLEAVE-NEXT: br label [[VECTOR_BODY:%.*]]
; INTERLEAVE: vector.body:
; INTERLEAVE-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE4:%.*]] ]
-; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi i1 [ [[ACTIVE_LANE_MASK_ENTRY]], [[ENTRY]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[PRED_STORE_CONTINUE4]] ]
+; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi i1 [ [[ACTIVE_LANE_MASK_ENTRY]], [[ENTRY]] ], [ true, [[PRED_STORE_CONTINUE4]] ]
; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK2:%.*]] = phi i1 [ [[ACTIVE_LANE_MASK_ENTRY1]], [[ENTRY]] ], [ [[ACTIVE_LANE_MASK_NEXT5:%.*]], [[PRED_STORE_CONTINUE4]] ]
; INTERLEAVE-NEXT: br i1 [[ACTIVE_LANE_MASK]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]]
; INTERLEAVE: pred.store.if:
@@ -229,7 +229,7 @@ define void @test_uniform_not_invariant(ptr noalias %dst, ptr readonly %src, i64
; INTERLEAVE: pred.store.continue4:
; INTERLEAVE-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2
; INTERLEAVE-NEXT: [[TMP10:%.*]] = or disjoint i64 [[INDEX]], 1
-; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = icmp ult i64 [[INDEX]], [[TMP0]]
+; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK_NEXT:%.*]] = icmp ult i64 [[INDEX]], [[TMP0]]
; INTERLEAVE-NEXT: [[ACTIVE_LANE_MASK_NEXT5]] = icmp ult i64 [[TMP10]], [[TMP0]]
; INTERLEAVE-NEXT: br i1 [[ACTIVE_LANE_MASK_NEXT]], label [[VECTOR_BODY]], label [[FOR_COND_CLEANUP:%.*]], !llvm.loop [[LOOP4:![0-9]+]]
; INTERLEAVE: for.cond.cleanup:
diff --git a/llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll b/llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll
index 335a850f1ec687..04bed80b55de2c 100644
--- a/llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll
+++ b/llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll
@@ -10,18 +10,13 @@ define i1 @test_order_1(ptr %this, ptr noalias %other, i1 %tobool9.not, i32 %cal
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[TOBOOL9_NOT]], label [[EXIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
; CHECK: for.cond.preheader:
-; CHECK-NEXT: [[CMP40_NOT3:%.*]] = icmp slt i32 [[CALL]], 1
+; CHECK-NEXT: [[CMP40_NOT3:%.*]] = icmp sgt i32 [[CALL]], 0
; CHECK-NEXT: br i1 [[CMP40_NOT3]], label [[FOR_COND41_PREHEADER_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.cond41.preheader.preheader:
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[CALL]] to i64
; CHECK-NEXT: br label [[FOR_COND41_PREHEADER:%.*]]
-; CHECK: for.cond:
-; CHECK-NEXT: [[INDVARS_IV_NEXT:%.*]] = add nsw i64 [[INDVARS_IV:%.*]], 1
-; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[INDVARS_IV_NEXT]], 4294967295
-; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[TMP1]], 1
-; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP]], label [[FOR_COND41_PREHEADER]]
; CHECK: for.cond41.preheader:
-; CHECK-NEXT: [[INDVARS_IV]] = phi i64 [ [[TMP0]], [[FOR_COND41_PREHEADER_PREHEADER]] ], [ [[INDVARS_IV_NEXT]], [[FOR_COND:%.*]] ]
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_COND_CLEANUP]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_COND:%.*]] ]
; CHECK-NEXT: [[CALL431:%.*]] = load volatile i32, ptr [[OTHER]], align 4
; CHECK-NEXT: [[CMP442:%.*]] = icmp sgt i32 [[CALL431]], 0
; CHECK-NEXT: br i1 [[CMP442]], label [[FOR_BODY45_LR_PH:%.*]], label [[FOR_COND]]
@@ -36,6 +31,11 @@ define i1 @test_order_1(ptr %this, ptr noalias %other, i1 %tobool9.not, i32 %cal
; CHECK-NEXT: [[CALL43:%.*]] = load volatile i32, ptr [[OTHER]], align 4
; CHECK-NEXT: [[CMP44:%.*]] = icmp sgt i32 [[CALL43]], 0
; CHECK-NEXT: br i1 [[CMP44]], label [[FOR_BODY45]], label [[FOR_COND]]
+; CHECK: for.inc57:
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[INDVARS_IV_NEXT]], 4294967295
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[TMP1]], 1
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND41_PREHEADER_PREHEADER]], label [[FOR_COND41_PREHEADER]]
; CHECK: exit:
; CHECK-NEXT: ret i1 false
;
diff --git a/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll b/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
index 80ccbc7378905a..5c5fd47b3624b9 100644
--- a/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
+++ b/llvm/test/Transforms/PhaseOrdering/branch-dom-cond.ll
@@ -14,9 +14,7 @@ define void @growTables(ptr %p) {
; CHECK-NEXT: [[CALL9:%.*]] = load volatile ptr, ptr [[P]], align 8
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_02]], 1
; CHECK-NEXT: [[CMP7:%.*]] = icmp slt i32 [[INC]], [[CALL]]
-; CHECK-NEXT: br i1 [[CMP7]], label %[[FOR_BODY]], label %[[FOR_END:.*]]
-; CHECK: [[FOR_END]]:
-; CHECK-NEXT: br i1 [[CMP71]], label %[[FOR_BODY12:.*]], label %[[COMMON_RET]]
+; CHECK-NEXT: br i1 [[CMP7]], label %[[FOR_BODY]], label %[[FOR_BODY12:.*]]
; CHECK: [[FOR_BODY12]]:
; CHECK-NEXT: [[CALL14:%.*]] = load volatile ptr, ptr [[P]], align 8
; CHECK-NEXT: br label %[[COMMON_RET]]
More information about the llvm-commits
mailing list