Skip to content

Commit 1ceede3

Browse files
committed
[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.
1 parent f1a29ec commit 1ceede3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -680,35 +680,28 @@ Constant *FatPtrConstMaterializer::materializeBufferFatPtrConst(Constant *C) {
680680
report_fatal_error(
681681
"Scalable vector or unsized struct in fat pointer GEP");
682682
Constant *OffAccum = nullptr;
683-
// Accumulate offsets together before adding to the base in order to
684-
// preserve as many of the inbounds properties as possible.
685683
for (auto [Arg, Multiple] : VariableOffs) {
686684
Constant *NewArg = InternalMapper.mapConstant(*cast<Constant>(Arg));
687685
NewArg = ConstantFoldIntegerCast(NewArg, OffTy, /*IsSigned=*/true, DL);
688686
if (!Multiple.isOne()) {
689687
if (Multiple.isPowerOf2()) {
690688
NewArg = ConstantExpr::getShl(
691-
NewArg,
692-
CE->getIntegerValue(
693-
OffTy, APInt(BufferOffsetWidth, Multiple.logBase2())),
694-
/*hasNUW=*/InBounds, /*HasNSW=*/InBounds);
689+
NewArg, CE->getIntegerValue(OffTy, APInt(BufferOffsetWidth,
690+
Multiple.logBase2())));
695691
} else {
696-
NewArg =
697-
ConstantExpr::getMul(NewArg, CE->getIntegerValue(OffTy, Multiple),
698-
/*hasNUW=*/InBounds, /*hasNSW=*/InBounds);
692+
NewArg = ConstantExpr::getMul(NewArg,
693+
CE->getIntegerValue(OffTy, Multiple));
699694
}
700695
}
701696
if (OffAccum) {
702-
OffAccum = ConstantExpr::getAdd(OffAccum, NewArg, /*hasNUW=*/InBounds,
703-
/*hasNSW=*/InBounds);
697+
OffAccum = ConstantExpr::getAdd(OffAccum, NewArg);
704698
} else {
705699
OffAccum = NewArg;
706700
}
707701
}
708702
Constant *NewConstOff = CE->getIntegerValue(OffTy, NewConstOffVal);
709703
if (OffAccum)
710-
OffAccum = ConstantExpr::getAdd(OffAccum, NewConstOff,
711-
/*hasNUW=*/InBounds, /*hasNSW=*/InBounds);
704+
OffAccum = ConstantExpr::getAdd(OffAccum, NewConstOff);
712705
else
713706
OffAccum = NewConstOff;
714707
bool HasNonNegativeOff = false;

0 commit comments

Comments
 (0)