[PATCH] D111691: [instcombine] propagate single use freeze(gep inbounds X)
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 09:25:16 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24c901657426: [instcombine] propagate single use freeze(gep inbounds X) (authored by reames).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111691/new/
https://reviews.llvm.org/D111691
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/freeze.ll
Index: llvm/test/Transforms/InstCombine/freeze.ll
===================================================================
--- llvm/test/Transforms/InstCombine/freeze.ll
+++ llvm/test/Transforms/InstCombine/freeze.ll
@@ -354,9 +354,9 @@
define i8* @propagate_drop_gep1(i8* %arg) {
; CHECK-LABEL: @propagate_drop_gep1(
-; CHECK-NEXT: [[V1:%.*]] = getelementptr inbounds i8, i8* [[ARG:%.*]], i64 16
-; CHECK-NEXT: [[V1_FR:%.*]] = freeze i8* [[V1]]
-; CHECK-NEXT: ret i8* [[V1_FR]]
+; CHECK-NEXT: [[ARG_FR:%.*]] = freeze i8* [[ARG:%.*]]
+; CHECK-NEXT: [[V1:%.*]] = getelementptr i8, i8* [[ARG_FR]], i64 16
+; CHECK-NEXT: ret i8* [[V1]]
;
%v1 = getelementptr inbounds i8, i8* %arg, i64 16
%v1.fr = freeze i8* %v1
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4959,6 +4959,9 @@
if (const auto *ExactOp = dyn_cast<PossiblyExactOperator>(Op))
if (ExactOp->isExact())
return true;
+ if (const auto *GEP = dyn_cast<GEPOperator>(Op))
+ if (GEP->isInBounds())
+ return true;
}
// TODO: this should really be under the ConsiderFlags block, but currently
@@ -5051,10 +5054,10 @@
case Instruction::ICmp:
case Instruction::FCmp:
return false;
- case Instruction::GetElementPtr: {
- const auto *GEP = cast<GEPOperator>(Op);
- return GEP->isInBounds();
- }
+ case Instruction::GetElementPtr:
+ // inbounds is handled above
+ // TODO: what about inrange on constexpr?
+ return false;
default: {
const auto *CE = dyn_cast<ConstantExpr>(Op);
if (isa<CastInst>(Op) || (CE && CE->isCast()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111691.379435.patch
Type: text/x-patch
Size: 1728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/51c53776/attachment-0001.bin>
More information about the llvm-commits
mailing list