aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-06-14 12:25:25 +0200
committerNikita Popov <npopov@redhat.com>2024-06-14 12:26:29 +0200
commit1ceede3318c29af83b219cca137f5e2c563fc871 (patch)
tree2a7ecda34428597a1e65c47e67f0063bb2cc2b2f
parentf1a29ec082ead82c6a4d61e515222d6bcf046a5b (diff)
downloadllvm-1ceede3318c29af83b219cca137f5e2c563fc871.zip
llvm-1ceede3318c29af83b219cca137f5e2c563fc871.tar.gz
llvm-1ceede3318c29af83b219cca137f5e2c563fc871.tar.bz2
[AMDGPULowerBufferFatPointers] Don't try to preserve flags for constant expressions
We expect all of these ConstantExpr ctors to fold away, don't try to preserve flags, especially as the flags are not correct.
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
index ea654db..0b261d8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
@@ -680,35 +680,28 @@ Constant *FatPtrConstMaterializer::materializeBufferFatPtrConst(Constant *C) {
report_fatal_error(
"Scalable vector or unsized struct in fat pointer GEP");
Constant *OffAccum = nullptr;
- // Accumulate offsets together before adding to the base in order to
- // preserve as many of the inbounds properties as possible.
for (auto [Arg, Multiple] : VariableOffs) {
Constant *NewArg = InternalMapper.mapConstant(*cast<Constant>(Arg));
NewArg = ConstantFoldIntegerCast(NewArg, OffTy, /*IsSigned=*/true, DL);
if (!Multiple.isOne()) {
if (Multiple.isPowerOf2()) {
NewArg = ConstantExpr::getShl(
- NewArg,
- CE->getIntegerValue(
- OffTy, APInt(BufferOffsetWidth, Multiple.logBase2())),
- /*hasNUW=*/InBounds, /*HasNSW=*/InBounds);
+ NewArg, CE->getIntegerValue(OffTy, APInt(BufferOffsetWidth,
+ Multiple.logBase2())));
} else {
- NewArg =
- ConstantExpr::getMul(NewArg, CE->getIntegerValue(OffTy, Multiple),
- /*hasNUW=*/InBounds, /*hasNSW=*/InBounds);
+ NewArg = ConstantExpr::getMul(NewArg,
+ CE->getIntegerValue(OffTy, Multiple));
}
}
if (OffAccum) {
- OffAccum = ConstantExpr::getAdd(OffAccum, NewArg, /*hasNUW=*/InBounds,
- /*hasNSW=*/InBounds);
+ OffAccum = ConstantExpr::getAdd(OffAccum, NewArg);
} else {
OffAccum = NewArg;
}
}
Constant *NewConstOff = CE->getIntegerValue(OffTy, NewConstOffVal);
if (OffAccum)
- OffAccum = ConstantExpr::getAdd(OffAccum, NewConstOff,
- /*hasNUW=*/InBounds, /*hasNSW=*/InBounds);
+ OffAccum = ConstantExpr::getAdd(OffAccum, NewConstOff);
else
OffAccum = NewConstOff;
bool HasNonNegativeOff = false;