[llvm] [ValueTracking] isNonZero sub of ptr2int's with recursive GEP (PR #68680)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 07:07:43 PST 2023
https://github.com/bipmis updated https://github.com/llvm/llvm-project/pull/68680
>From bddd146780de7dae9a1f055894034e673023be6d Mon Sep 17 00:00:00 2001
From: bipmis <biplob.mishra at arm.com>
Date: Fri, 15 Dec 2023 12:55:31 +0000
Subject: [PATCH 1/2] Precommit tests for isNonZeroSub with a Recursive GEP
---
.../Analysis/ValueTracking/phi-known-bits.ll | 133 ++++++++++++++++++
1 file changed, 133 insertions(+)
diff --git a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
index 450b3b864c1920..2e4a5fab110e85 100644
--- a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
+++ b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
@@ -989,3 +989,136 @@ while.end.i:
%bool = icmp eq i64 %sub.ptr.sub.i, 0
ret i1 %bool
}
+
+; Test cmp(or), where one of argument to OR is a SUB of ptr2int with a recursive GEP.
+define i1 @recursiveGEP_orcmp(ptr %val1, i64 %val2) {
+; CHECK-LABEL: @recursiveGEP_orcmp(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
+; CHECK: while.cond.i:
+; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
+; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
+; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
+; CHECK: while.end.i:
+; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
+; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
+; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
+; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
+; CHECK-NEXT: [[BOOL:%.*]] = icmp eq i64 [[ORVAL]], 0
+; CHECK-NEXT: ret i1 [[BOOL]]
+;
+entry:
+ br label %while.cond.i
+
+while.cond.i:
+ %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
+ %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
+ %0 = load i8, ptr %test.0.i, align 2
+ %cmp3.not.i = icmp eq i8 %0, 0
+ br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
+
+while.end.i:
+ %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
+ %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
+ %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
+ %orval = or i64 %sub.ptr.sub.i, %val2
+ %bool = icmp eq i64 %orval, 0
+ ret i1 %bool
+}
+
+define i1 @recursiveGEP_orcmp_orOperandsCommuted(ptr %val1, i64 %val2) {
+; CHECK-LABEL: @recursiveGEP_orcmp_orOperandsCommuted(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
+; CHECK: while.cond.i:
+; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
+; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
+; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
+; CHECK: while.end.i:
+; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
+; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
+; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
+; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
+; CHECK-NEXT: [[BOOL:%.*]] = icmp eq i64 [[ORVAL]], 0
+; CHECK-NEXT: ret i1 [[BOOL]]
+;
+entry:
+ br label %while.cond.i
+
+while.cond.i:
+ %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
+ %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
+ %0 = load i8, ptr %test.0.i, align 2
+ %cmp3.not.i = icmp eq i8 %0, 0
+ br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
+
+while.end.i:
+ %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
+ %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
+ %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
+ %orval = or i64 %val2, %sub.ptr.sub.i
+ %bool = icmp eq i64 %orval, 0
+ ret i1 %bool
+}
+
+; Test one of the argument to SUB is a ptr2int of a recursive GEP, with multiple use of SUB.
+define i1 @recursiveGEP_orcmpMultiUse(ptr %val1, i64 %val2, ptr %dv1, ptr %dv2) {
+; CHECK-LABEL: @recursiveGEP_orcmpMultiUse(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
+; CHECK: while.cond.i:
+; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1
+; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2
+; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
+; CHECK: while.end.i:
+; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
+; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
+; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
+; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = icmp eq i64 [[ORVAL]], 0
+; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_THEN:%.*]], label [[IF_END4:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[DV1:%.*]], [[DV2:%.*]]
+; CHECK-NEXT: br label [[CLEANUP:%.*]]
+; CHECK: if.end4:
+; CHECK-NEXT: br label [[CLEANUP]]
+; CHECK: cleanup:
+; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i1 [ [[CMP]], [[IF_THEN]] ], [ true, [[IF_END4]] ]
+; CHECK-NEXT: ret i1 [[RETVAL_0]]
+;
+entry:
+ br label %while.cond.i
+
+while.cond.i:
+ %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ]
+ %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1
+ %0 = load i8, ptr %test.0.i, align 2
+ %cmp3.not.i = icmp eq i8 %0, 0
+ br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i
+
+while.end.i:
+ %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i64
+ %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i64
+ %sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
+ %orval = or i64 %sub.ptr.sub.i, %val2
+ %or.cond = icmp eq i64 %orval, 0
+ br i1 %or.cond, label %if.then, label %if.end4
+
+if.then:
+ %cmp = icmp eq ptr %dv1, %dv2
+ br label %cleanup
+
+if.end4:
+ %tobool = icmp ne i64 %sub.ptr.sub.i, 0
+ br label %cleanup
+
+cleanup:
+ %retval.0 = phi i1 [ %cmp, %if.then ], [ %tobool, %if.end4 ]
+ ret i1 %retval.0
+}
>From 1e41185cc463f947e6d85771449cd131d40af557 Mon Sep 17 00:00:00 2001
From: bipmis <biplob.mishra at arm.com>
Date: Fri, 15 Dec 2023 15:07:18 +0000
Subject: [PATCH 2/2] Update isNonZeroSub to handle Recursive GEP
---
llvm/lib/Analysis/ValueTracking.cpp | 112 ++++++++++--------
.../Analysis/ValueTracking/phi-known-bits.ll | 25 +---
llvm/test/Transforms/InstCombine/sub-gep.ll | 9 +-
3 files changed, 67 insertions(+), 79 deletions(-)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 9ae05a4b5ccc72..bf46ecac2fce3f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2365,9 +2365,69 @@ static bool isNonZeroAdd(const APInt &DemandedElts, unsigned Depth,
.isNonZero();
}
+// Check to see if A is both a GEP and is the incoming value for a PHI in the
+// loop, and B is either a ptr or another GEP. If the PHI has 2 incoming values,
+// one of them being the recursive GEP A and the other a ptr at same base and at
+// the same/higher offset than B we are only incrementing the pointer further in
+// loop if offset of recursive GEP is greater than 0.
+static bool isNonEqualPointersWithRecursiveGEP(const Value *A, const Value *B,
+ const SimplifyQuery &Q) {
+ if (!A->getType()->isPointerTy() || !B->getType()->isPointerTy())
+ return false;
+
+ auto *GEPA = dyn_cast<GEPOperator>(A);
+ if (!GEPA || GEPA->getNumIndices() != 1 || !isa<Constant>(GEPA->idx_begin()))
+ return false;
+
+ // Handle 2 incoming PHI values with one being a recursive GEP.
+ auto *PN = dyn_cast<PHINode>(GEPA->getPointerOperand());
+ if (!PN || PN->getNumIncomingValues() != 2)
+ return false;
+
+ // Search for the recursive GEP as an incoming operand, and record that as
+ // Step.
+ Value *Start = nullptr;
+ Value *Step = const_cast<Value *>(A);
+ if (PN->getIncomingValue(0) == Step)
+ Start = PN->getIncomingValue(1);
+ else if (PN->getIncomingValue(1) == Step)
+ Start = PN->getIncomingValue(0);
+ else
+ return false;
+
+ // Other incoming node base should match the B base.
+ // StartOffset >= OffsetB && StepOffset > 0?
+ // StartOffset <= OffsetB && StepOffset < 0?
+ // Is non-equal if above are true.
+ // We use stripAndAccumulateInBoundsConstantOffsets to restrict the
+ // optimisation to inbounds GEPs only.
+ unsigned IndexWidth = Q.DL.getIndexTypeSizeInBits(Start->getType());
+ APInt StartOffset(IndexWidth, 0);
+ Start = Start->stripAndAccumulateInBoundsConstantOffsets(Q.DL, StartOffset);
+ APInt StepOffset(IndexWidth, 0);
+ Step = Step->stripAndAccumulateInBoundsConstantOffsets(Q.DL, StepOffset);
+
+ // Check if Base Pointer of Step matches the PHI.
+ if (Step != PN)
+ return false;
+ APInt OffsetB(IndexWidth, 0);
+ B = B->stripAndAccumulateInBoundsConstantOffsets(Q.DL, OffsetB);
+ return Start == B &&
+ ((StartOffset.sge(OffsetB) && StepOffset.isStrictlyPositive()) ||
+ (StartOffset.sle(OffsetB) && StepOffset.isNegative()));
+}
+
static bool isNonZeroSub(const APInt &DemandedElts, unsigned Depth,
const SimplifyQuery &Q, unsigned BitWidth, Value *X,
Value *Y) {
+ // sub(PtrtoInt(A), PtrtoInt(B))
+ // Sub is a NonZero if the Ptr A and B are NonEqual.
+ Value *A, *B;
+ if (match(X, m_PtrToInt(m_Value(A))) && match(Y, m_PtrToInt(m_Value(B))))
+ if (isNonEqualPointersWithRecursiveGEP(A, B, Q) ||
+ isNonEqualPointersWithRecursiveGEP(B, A, Q))
+ return true;
+
if (auto *C = dyn_cast<Constant>(X))
if (C->isNullValue() && isKnownNonZero(Y, DemandedElts, Depth, Q))
return true;
@@ -3096,58 +3156,6 @@ static bool isNonEqualSelect(const Value *V1, const Value *V2, unsigned Depth,
isKnownNonEqual(SI1->getFalseValue(), V2, Depth + 1, Q);
}
-// Check to see if A is both a GEP and is the incoming value for a PHI in the
-// loop, and B is either a ptr or another GEP. If the PHI has 2 incoming values,
-// one of them being the recursive GEP A and the other a ptr at same base and at
-// the same/higher offset than B we are only incrementing the pointer further in
-// loop if offset of recursive GEP is greater than 0.
-static bool isNonEqualPointersWithRecursiveGEP(const Value *A, const Value *B,
- const SimplifyQuery &Q) {
- if (!A->getType()->isPointerTy() || !B->getType()->isPointerTy())
- return false;
-
- auto *GEPA = dyn_cast<GEPOperator>(A);
- if (!GEPA || GEPA->getNumIndices() != 1 || !isa<Constant>(GEPA->idx_begin()))
- return false;
-
- // Handle 2 incoming PHI values with one being a recursive GEP.
- auto *PN = dyn_cast<PHINode>(GEPA->getPointerOperand());
- if (!PN || PN->getNumIncomingValues() != 2)
- return false;
-
- // Search for the recursive GEP as an incoming operand, and record that as
- // Step.
- Value *Start = nullptr;
- Value *Step = const_cast<Value *>(A);
- if (PN->getIncomingValue(0) == Step)
- Start = PN->getIncomingValue(1);
- else if (PN->getIncomingValue(1) == Step)
- Start = PN->getIncomingValue(0);
- else
- return false;
-
- // Other incoming node base should match the B base.
- // StartOffset >= OffsetB && StepOffset > 0?
- // StartOffset <= OffsetB && StepOffset < 0?
- // Is non-equal if above are true.
- // We use stripAndAccumulateInBoundsConstantOffsets to restrict the
- // optimisation to inbounds GEPs only.
- unsigned IndexWidth = Q.DL.getIndexTypeSizeInBits(Start->getType());
- APInt StartOffset(IndexWidth, 0);
- Start = Start->stripAndAccumulateInBoundsConstantOffsets(Q.DL, StartOffset);
- APInt StepOffset(IndexWidth, 0);
- Step = Step->stripAndAccumulateInBoundsConstantOffsets(Q.DL, StepOffset);
-
- // Check if Base Pointer of Step matches the PHI.
- if (Step != PN)
- return false;
- APInt OffsetB(IndexWidth, 0);
- B = B->stripAndAccumulateInBoundsConstantOffsets(Q.DL, OffsetB);
- return Start == B &&
- ((StartOffset.sge(OffsetB) && StepOffset.isStrictlyPositive()) ||
- (StartOffset.sle(OffsetB) && StepOffset.isNegative()));
-}
-
/// Return true if it is known that V1 != V2.
static bool isKnownNonEqual(const Value *V1, const Value *V2, unsigned Depth,
const SimplifyQuery &Q) {
diff --git a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
index 2e4a5fab110e85..e5b8ba151e04c2 100644
--- a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
+++ b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll
@@ -1002,12 +1002,7 @@ define i1 @recursiveGEP_orcmp(ptr %val1, i64 %val2) {
; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
; CHECK: while.end.i:
-; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
-; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
-; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
-; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
-; CHECK-NEXT: [[BOOL:%.*]] = icmp eq i64 [[ORVAL]], 0
-; CHECK-NEXT: ret i1 [[BOOL]]
+; CHECK-NEXT: ret i1 false
;
entry:
br label %while.cond.i
@@ -1039,12 +1034,7 @@ define i1 @recursiveGEP_orcmp_orOperandsCommuted(ptr %val1, i64 %val2) {
; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
; CHECK: while.end.i:
-; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
-; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
-; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
-; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
-; CHECK-NEXT: [[BOOL:%.*]] = icmp eq i64 [[ORVAL]], 0
-; CHECK-NEXT: ret i1 [[BOOL]]
+; CHECK-NEXT: ret i1 false
;
entry:
br label %while.cond.i
@@ -1077,20 +1067,13 @@ define i1 @recursiveGEP_orcmpMultiUse(ptr %val1, i64 %val2, ptr %dv1, ptr %dv2)
; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0
; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
; CHECK: while.end.i:
-; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
-; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i64
-; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
-; CHECK-NEXT: [[ORVAL:%.*]] = or i64 [[SUB_PTR_SUB_I]], [[VAL2:%.*]]
-; CHECK-NEXT: [[OR_COND:%.*]] = icmp eq i64 [[ORVAL]], 0
-; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_THEN:%.*]], label [[IF_END4:%.*]]
+; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_END4:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[DV1:%.*]], [[DV2:%.*]]
; CHECK-NEXT: br label [[CLEANUP:%.*]]
; CHECK: if.end4:
; CHECK-NEXT: br label [[CLEANUP]]
; CHECK: cleanup:
-; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i1 [ [[CMP]], [[IF_THEN]] ], [ true, [[IF_END4]] ]
-; CHECK-NEXT: ret i1 [[RETVAL_0]]
+; CHECK-NEXT: ret i1 true
;
entry:
br label %while.cond.i
diff --git a/llvm/test/Transforms/InstCombine/sub-gep.ll b/llvm/test/Transforms/InstCombine/sub-gep.ll
index a03b67f934315f..5130883409b28d 100644
--- a/llvm/test/Transforms/InstCombine/sub-gep.ll
+++ b/llvm/test/Transforms/InstCombine/sub-gep.ll
@@ -449,8 +449,8 @@ define i1 @_gep_phi1(ptr %str1) {
; CHECK: while.end.i:
; CHECK-NEXT: br label [[_Z3FOOPKC_EXIT]]
; CHECK: _Z3fooPKc.exit:
-; CHECK-NEXT: [[RETVAL_0_I:%.*]] = phi i1 [ true, [[WHILE_END_I]] ], [ false, [[LOR_LHS_FALSE_I]] ], [ false, [[ENTRY:%.*]] ]
-; CHECK-NEXT: ret i1 [[RETVAL_0_I]]
+; CHECK-NEXT: [[TOBOOL:%.*]] = phi i1 [ true, [[WHILE_END_I]] ], [ false, [[LOR_LHS_FALSE_I]] ], [ false, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i1 [[TOBOOL]]
;
entry:
%cmp.i = icmp eq ptr %str1, null
@@ -496,12 +496,9 @@ define i1 @_gep_phi2(ptr %str1, i64 %val2) {
; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP1]], 0
; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]]
; CHECK: while.end.i:
-; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i64
-; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[STR1]] to i64
-; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i64 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]]
; CHECK-NEXT: br label [[_Z3FOOPKC_EXIT]]
; CHECK: _Z3fooPKc.exit:
-; CHECK-NEXT: [[RETVAL_0_I:%.*]] = phi i64 [ [[SUB_PTR_SUB_I]], [[WHILE_END_I]] ], [ 0, [[LOR_LHS_FALSE_I]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[RETVAL_0_I:%.*]] = phi i64 [ 1, [[WHILE_END_I]] ], [ 0, [[LOR_LHS_FALSE_I]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: [[TMP2:%.*]] = or i64 [[RETVAL_0_I]], [[VAL2:%.*]]
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[TMP2]], 0
; CHECK-NEXT: ret i1 [[TOBOOL]]
More information about the llvm-commits
mailing list