[llvm] 69f64de - [RISCV] Use DemandedFields instead of checking for vmv.s.x/vmv.x.s. NFC

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 19 21:24:36 PST 2023


Author: Luke Lau
Date: 2023-11-20T13:16:54+08:00
New Revision: 69f64dedb09bf39bd3ad66bcbc2c947b23342a11

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

LOG: [RISCV] Use DemandedFields instead of checking for vmv.s.x/vmv.x.s. NFC

The property we're explicitly looking for is whether or not MI only cares about
VL zeroness and not VL itself, so we can just use DemandedFields for this. This
should simplify an upcoming change in #72352

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 999ff9920716e87..a7b0bb372bbfe6d 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -1043,17 +1043,16 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
       Info.setVLMul(*NewVLMul);
   }
 
-  // For vmv.s.x and vfmv.s.f, there are only two behaviors, VL = 0 and
-  // VL > 0. We can discard the user requested AVL and just use the last
-  // one if we can prove it equally zero.  This removes a vsetvli entirely
-  // if the types match or allows use of cheaper avl preserving variant
-  // if VLMAX doesn't change.  If VLMAX might change, we couldn't use
-  // the 'vsetvli x0, x0, vtype" variant, so we avoid the transform to
-  // prevent extending live range of an avl register operand.
+  // If we only demand VL zeroness (i.e. vmv.s.x and vmv.x.s), then there are
+  // only two behaviors, VL = 0 and VL > 0. We can discard the user requested
+  // AVL and just use the last one if we can prove it equally zero. This
+  // removes a vsetvli entirely if the types match or allows use of cheaper avl
+  // preserving variant if VLMAX doesn't change. If VLMAX might change, we
+  // couldn't use the 'vsetvli x0, x0, vtype" variant, so we avoid the transform
+  // to prevent extending live range of an avl register operand.
   // TODO: We can probably relax this for immediates.
-  if (isScalarInsertInstr(MI) && PrevInfo.isValid() &&
-      PrevInfo.hasEquallyZeroAVL(Info, *MRI) &&
-      Info.hasSameVLMAX(PrevInfo)) {
+  if (Demanded.VLZeroness && !Demanded.VLAny && PrevInfo.isValid() &&
+      PrevInfo.hasEquallyZeroAVL(Info, *MRI) && Info.hasSameVLMAX(PrevInfo)) {
     if (PrevInfo.hasAVLImm())
       Info.setAVLImm(PrevInfo.getAVLImm());
     else


        


More information about the llvm-commits mailing list