[PATCH] D154215: [InstSimplify] Fold gep inbounds undef to undef instead of poison
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 6 05:59:32 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c7fd723c460: [InstSimplify] Fold gep inbounds undef to undef instead of poison (authored by nikic).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154215/new/
https://reviews.llvm.org/D154215
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/gep.ll
Index: llvm/test/Transforms/InstSimplify/gep.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/gep.ll
+++ llvm/test/Transforms/InstSimplify/gep.ll
@@ -160,7 +160,7 @@
define ptr @undef_inbounds_var_idx(i64 %idx) {
; CHECK-LABEL: @undef_inbounds_var_idx(
-; CHECK-NEXT: ret ptr poison
+; CHECK-NEXT: ret ptr undef
;
%el = getelementptr inbounds i64, ptr undef, i64 %idx
ret ptr %el
@@ -176,7 +176,7 @@
define <8 x ptr> @undef_vec1() {
; CHECK-LABEL: @undef_vec1(
-; CHECK-NEXT: ret <8 x ptr> poison
+; CHECK-NEXT: ret <8 x ptr> undef
;
%el = getelementptr inbounds i64, ptr undef, <8 x i64> undef
ret <8 x ptr> %el
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4896,9 +4896,9 @@
any_of(Indices, [](const auto *V) { return isa<PoisonValue>(V); }))
return PoisonValue::get(GEPTy);
+ // getelementptr undef, idx -> undef
if (Q.isUndefValue(Ptr))
- // If inbounds, we can choose an out-of-bounds pointer as a base pointer.
- return InBounds ? PoisonValue::get(GEPTy) : UndefValue::get(GEPTy);
+ return UndefValue::get(GEPTy);
bool IsScalableVec =
isa<ScalableVectorType>(SrcTy) || any_of(Indices, [](const Value *V) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154215.537684.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230706/a56593bd/attachment.bin>
More information about the llvm-commits
mailing list