[llvm] ebaac2b - Revert "[AArch64][NFC] Call the API getVScaleRange directly"

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 01:44:25 PDT 2023


Author: Zhongyunde
Date: 2023-07-26T16:44:14+08:00
New Revision: ebaac2b2d69ead939c89e8ca67eb83b29b7d5a0e

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

LOG: Revert "[AArch64][NFC] Call the API getVScaleRange directly"

This reverts commit 67005c8e6fa9464f8bc436305a422071013ae499.

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionSimplify.cpp
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/lib/Target/AArch64/AArch64TargetMachine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 343a011119c196..0bfea6140ab548 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6539,10 +6539,13 @@ static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
   if (!NumOperands) {
     switch (IID) {
     case Intrinsic::vscale: {
-      Type *RetTy = F->getReturnType();
-      ConstantRange CR = getVScaleRange(Call->getFunction(), 64);
-      if (const APInt *C = CR.getSingleElement())
-        return ConstantInt::get(RetTy, C->getZExtValue());
+      auto Attr = Call->getFunction()->getFnAttribute(Attribute::VScaleRange);
+      if (!Attr.isValid())
+        return nullptr;
+      unsigned VScaleMin = Attr.getVScaleRangeMin();
+      std::optional<unsigned> VScaleMax = Attr.getVScaleRangeMax();
+      if (VScaleMax && VScaleMin == VScaleMax)
+        return ConstantInt::get(F->getReturnType(), VScaleMin);
       return nullptr;
     }
     default:

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index ec84878f298854..5c1b19eba1c1f0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1947,10 +1947,13 @@ SDValue SelectionDAG::getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
 
   if (ConstantFold) {
     const MachineFunction &MF = getMachineFunction();
-    const Function &F = MF.getFunction();
-    ConstantRange CR = getVScaleRange(&F, 64);
-    if (const APInt *C = CR.getSingleElement())
-      return getConstant(MulImm * C->getZExtValue(), DL, VT);
+    auto Attr = MF.getFunction().getFnAttribute(Attribute::VScaleRange);
+    if (Attr.isValid()) {
+      unsigned VScaleMin = Attr.getVScaleRangeMin();
+      if (std::optional<unsigned> VScaleMax = Attr.getVScaleRangeMax())
+        if (*VScaleMax == VScaleMin)
+          return getConstant(MulImm * VScaleMin, DL, VT);
+    }
   }
 
   return getNode(ISD::VSCALE, DL, VT, getConstant(MulImm, DL, VT));

diff  --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index aed26e12caea39..559879139758ba 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -21,7 +21,6 @@
 #include "TargetInfo/AArch64TargetInfo.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/CFIFixup.h"
 #include "llvm/CodeGen/CSEConfigBase.h"
 #include "llvm/CodeGen/GlobalISel/CSEInfo.h"
@@ -399,10 +398,11 @@ AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
 
   unsigned MinSVEVectorSize = 0;
   unsigned MaxSVEVectorSize = 0;
-  if (F.hasFnAttribute(Attribute::VScaleRange)) {
-    ConstantRange CR = getVScaleRange(&F, 64);
-    MinSVEVectorSize = CR.getUnsignedMin().getZExtValue() * 128;
-    MaxSVEVectorSize = CR.getUnsignedMax().getZExtValue() * 128;
+  Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
+  if (VScaleRangeAttr.isValid()) {
+    std::optional<unsigned> VScaleMax = VScaleRangeAttr.getVScaleRangeMax();
+    MinSVEVectorSize = VScaleRangeAttr.getVScaleRangeMin() * 128;
+    MaxSVEVectorSize = VScaleMax ? *VScaleMax * 128 : 0;
   } else {
     MinSVEVectorSize = SVEVectorBitsMinOpt;
     MaxSVEVectorSize = SVEVectorBitsMaxOpt;
@@ -417,10 +417,12 @@ AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
 
   // Sanitize user input in case of no asserts
   if (MaxSVEVectorSize == 0)
-    MinSVEVectorSize = MinSVEVectorSize;
+    MinSVEVectorSize = (MinSVEVectorSize / 128) * 128;
   else {
-    MinSVEVectorSize = std::min(MinSVEVectorSize, MaxSVEVectorSize);
-    MaxSVEVectorSize = std::max(MinSVEVectorSize, MaxSVEVectorSize);
+    MinSVEVectorSize =
+        (std::min(MinSVEVectorSize, MaxSVEVectorSize) / 128) * 128;
+    MaxSVEVectorSize =
+        (std::max(MinSVEVectorSize, MaxSVEVectorSize) / 128) * 128;
   }
 
   SmallString<512> Key;


        


More information about the llvm-commits mailing list