aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-05-28 11:08:42 +0200
committerNikita Popov <npopov@redhat.com>2024-05-28 11:14:07 +0200
commit1383cb6e648ba9f4516fa2317f948116c4f35c10 (patch)
tree922c82a09aef4b8b36e73107e64e65ba388f3474 /llvm/lib/IR/ConstantFold.cpp
parent4d3284cadfa0dc9850d58b97e943481a30c39c1b (diff)
downloadllvm-1383cb6e648ba9f4516fa2317f948116c4f35c10.zip
llvm-1383cb6e648ba9f4516fa2317f948116c4f35c10.tar.gz
llvm-1383cb6e648ba9f4516fa2317f948116c4f35c10.tar.bz2
[ConstFold] Fix incorrect gep inbounds of undef fold
gep inbounds of undef can only be folded to poison if we know that the offset is non-zero. I don't think precise handling here is important, so just drop the inbounds special case. This matches what InstSimplify does.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 4c5e1ce..8fce782 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1549,8 +1549,7 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
return PoisonValue::get(GEPTy);
if (isa<UndefValue>(C))
- // 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);
auto IsNoOp = [&]() {
// Avoid losing inrange information.