[llvm] adbdf27 - [CodeGenPrepare] Stop llvm.vscale() -> getelementptr(null, 1) transformation.

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 07:48:02 PST 2023


Author: Paul Walker
Date: 2023-03-08T15:47:03Z
New Revision: adbdf273efd584e58e7ef57d391b4e1885e7837f

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

LOG: [CodeGenPrepare] Stop llvm.vscale() -> getelementptr(null, 1) transformation.

I've pulled this change from D145404 to land in isolation because
I'm concerned the code might be more important than the test
coverage might suggest (NOTE: the code has no test coverage).

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 0aa218a78f129..79cd7060db43d 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2349,24 +2349,6 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, ModifyDT &ModifiedDT) {
     case Intrinsic::dbg_assign:
     case Intrinsic::dbg_value:
       return fixupDbgValue(II);
-    case Intrinsic::vscale: {
-      // If datalayout has no special restrictions on vector data layout,
-      // replace `llvm.vscale` by an equivalent constant expression
-      // to benefit from cheap constant propagation.
-      Type *ScalableVectorTy =
-          VectorType::get(Type::getInt8Ty(II->getContext()), 1, true);
-      if (DL->getTypeAllocSize(ScalableVectorTy).getKnownMinValue() == 8) {
-        auto *Null = Constant::getNullValue(ScalableVectorTy->getPointerTo());
-        auto *One = ConstantInt::getSigned(II->getType(), 1);
-        auto *CGep =
-            ConstantExpr::getGetElementPtr(ScalableVectorTy, Null, One);
-        replaceAllUsesWith(II, ConstantExpr::getPtrToInt(CGep, II->getType()),
-                           FreshBBs, IsHugeFunc);
-        II->eraseFromParent();
-        return true;
-      }
-      break;
-    }
     case Intrinsic::masked_gather:
       return optimizeGatherScatterInst(II, II->getArgOperand(0));
     case Intrinsic::masked_scatter:


        


More information about the llvm-commits mailing list