[llvm] 1ceede3 - [AMDGPULowerBufferFatPointers] Don't try to preserve flags for constant expressions

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 03:26:37 PDT 2024


Author: Nikita Popov
Date: 2024-06-14T12:26:29+02:00
New Revision: 1ceede3318c29af83b219cca137f5e2c563fc871

URL: https://github.com/llvm/llvm-project/commit/1ceede3318c29af83b219cca137f5e2c563fc871
DIFF: https://github.com/llvm/llvm-project/commit/1ceede3318c29af83b219cca137f5e2c563fc871.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
index ea654dbd487bc..0b261d8e33907 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;


        


More information about the llvm-commits mailing list