[llvm] 4858e08 - [ConstraintElimination] Only strip casts preserving the representation.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 26 13:09:29 PDT 2021
Author: Florian Hahn
Date: 2021-03-26T20:07:41Z
New Revision: 4858e081d764537309e8200f144402fb73d603e4
URL: https://github.com/llvm/llvm-project/commit/4858e081d764537309e8200f144402fb73d603e4
DIFF: https://github.com/llvm/llvm-project/commit/4858e081d764537309e8200f144402fb73d603e4.diff
LOG: [ConstraintElimination] Only strip casts preserving the representation.
Things like addrspacecast may not be no-ops, so we should not look
through them.
Added:
Modified:
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/pointercast.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index f133f865945f8..16cde39ecff93 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -166,8 +166,8 @@ getConstraint(CmpInst::Predicate Pred, Value *Op0, Value *Op1,
if (Pred != CmpInst::ICMP_ULE && Pred != CmpInst::ICMP_ULT)
return {};
- auto ADec = decompose(Op0->stripPointerCasts());
- auto BDec = decompose(Op1->stripPointerCasts());
+ auto ADec = decompose(Op0->stripPointerCastsSameRepresentation());
+ auto BDec = decompose(Op1->stripPointerCastsSameRepresentation());
// Skip if decomposing either of the values failed.
if (ADec.empty() || BDec.empty())
return {};
diff --git a/llvm/test/Transforms/ConstraintElimination/pointercast.ll b/llvm/test/Transforms/ConstraintElimination/pointercast.ll
index 5811b69118caf..acd0fbcdcf9bb 100644
--- a/llvm/test/Transforms/ConstraintElimination/pointercast.ll
+++ b/llvm/test/Transforms/ConstraintElimination/pointercast.ll
@@ -174,19 +174,19 @@ define i1 @addrspacecast_and_cmp(i32* readonly %src, i32* readnone %min, i32* re
; CHECK: checks:
; CHECK-NEXT: [[C_3_MIN:%.*]] = icmp ult i32* [[GEP_3]], [[MIN]]
; CHECK-NEXT: [[C_3_MAX:%.*]] = icmp ult i32* [[GEP_3]], [[MAX]]
-; CHECK-NEXT: [[RES_1:%.*]] = xor i1 false, [[C_3_MAX]]
+; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[C_3_MIN]], [[C_3_MAX]]
; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 1
; CHECK-NEXT: [[C_1_MIN:%.*]] = icmp ult i32* [[GEP_1]], [[MIN]]
; CHECK-NEXT: [[C_1_MAX:%.*]] = icmp ult i32* [[GEP_1]], [[MAX]]
-; CHECK-NEXT: [[RES_2:%.*]] = xor i1 false, true
+; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[C_1_MIN]], [[C_1_MAX]]
; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 2
; CHECK-NEXT: [[C_2_MIN:%.*]] = icmp ult i32* [[GEP_2]], [[MIN]]
; CHECK-NEXT: [[C_2_MAX:%.*]] = icmp ult i32* [[GEP_2]], [[MAX]]
-; CHECK-NEXT: [[RES_3:%.*]] = xor i1 false, true
+; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[C_2_MIN]], [[C_2_MAX]]
; CHECK-NEXT: [[GEP_4:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 4
; CHECK-NEXT: [[C_4_MIN:%.*]] = icmp ult i32* [[GEP_4]], [[MIN]]
; CHECK-NEXT: [[C_4_MAX:%.*]] = icmp ult i32* [[GEP_4]], [[MAX]]
-; CHECK-NEXT: [[RES_4:%.*]] = xor i1 false, [[C_4_MAX]]
+; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[C_4_MIN]], [[C_4_MAX]]
; CHECK-NEXT: [[RES_5:%.*]] = xor i1 [[RES_1]], [[RES_2]]
; CHECK-NEXT: [[RES_6:%.*]] = xor i1 [[RES_5]], [[RES_3]]
; CHECK-NEXT: [[RES_7:%.*]] = xor i1 [[RES_6]], [[RES_4]]
More information about the llvm-commits
mailing list