[llvm] 7aa7393 - [DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 05:12:45 PDT 2023


Author: Simon Pilgrim
Date: 2023-03-16T12:12:33Z
New Revision: 7aa7393aab9f912c0aa8f83d45de6cdd6e4c2223

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

LOG: [DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 8cb1055e2661..6d7977b766a7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -559,11 +559,12 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
   assert(Op.getNode()->getNumValues() == 1 &&
          "ShrinkDemandedOp only supports nodes with one result!");
 
+  EVT VT = Op.getValueType();
   SelectionDAG &DAG = TLO.DAG;
   SDLoc dl(Op);
 
   // Early return, as this function cannot handle vector types.
-  if (Op.getValueType().isVector())
+  if (VT.isVector())
     return false;
 
   // Don't do this if the node has another user, which may require the
@@ -579,15 +580,14 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
   SmallVTBits = llvm::bit_ceil(SmallVTBits);
   for (; SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2(SmallVTBits)) {
     EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), SmallVTBits);
-    if (TLI.isTruncateFree(Op.getValueType(), SmallVT) &&
-        TLI.isZExtFree(SmallVT, Op.getValueType())) {
+    if (TLI.isTruncateFree(VT, SmallVT) && TLI.isZExtFree(SmallVT, VT)) {
       // We found a type with free casts.
       SDValue X = DAG.getNode(
           Op.getOpcode(), dl, SmallVT,
           DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(0)),
           DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(1)));
       assert(DemandedSize <= SmallVTBits && "Narrowed below demanded bits?");
-      SDValue Z = DAG.getNode(ISD::ANY_EXTEND, dl, Op.getValueType(), X);
+      SDValue Z = DAG.getNode(ISD::ANY_EXTEND, dl, VT, X);
       return TLO.CombineTo(Op, Z);
     }
   }


        


More information about the llvm-commits mailing list