[llvm] d08496b - [AMDGPULowerKernelAttribute] Avoid use of ConstantExpr::getIntegerCast() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 04:11:10 PDT 2023


Author: Nikita Popov
Date: 2023-11-01T12:11:02+01:00
New Revision: d08496b51cc97d1d73d55a733cd0ec68e5fe9e84

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

LOG: [AMDGPULowerKernelAttribute] Avoid use of ConstantExpr::getIntegerCast() (NFC)

We are working on ConstantInt here, so folding will always succeed.
This just avoids use of the ConstantExpr API.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
index 26074cf06071478..097722157d41033 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
@@ -14,6 +14,7 @@
 
 #include "AMDGPU.h"
 #include "Utils/AMDGPUBaseInfo.h"
+#include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
@@ -286,8 +287,8 @@ static bool processUse(CallInst *CI, bool IsV5OrAbove) {
             if (HasReqdWorkGroupSize) {
               ConstantInt *KnownSize
                 = mdconst::extract<ConstantInt>(MD->getOperand(I));
-              UMin->replaceAllUsesWith(ConstantExpr::getIntegerCast(
-                  KnownSize, UMin->getType(), false));
+              UMin->replaceAllUsesWith(ConstantFoldIntegerCast(
+                  KnownSize, UMin->getType(), false, DL));
             } else {
               UMin->replaceAllUsesWith(ZextGroupSize);
             }
@@ -310,7 +311,7 @@ static bool processUse(CallInst *CI, bool IsV5OrAbove) {
 
     ConstantInt *KnownSize = mdconst::extract<ConstantInt>(MD->getOperand(I));
     GroupSize->replaceAllUsesWith(
-        ConstantExpr::getIntegerCast(KnownSize, GroupSize->getType(), false));
+        ConstantFoldIntegerCast(KnownSize, GroupSize->getType(), false, DL));
     MadeChange = true;
   }
 


        


More information about the llvm-commits mailing list