[llvm] [RISCV] Use significant bits helpers in narrowing of build vectors [nfc] (PR #104511)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 14:24:54 PDT 2024
https://github.com/preames created https://github.com/llvm/llvm-project/pull/104511
(Should be near trivial, posted for review mostly because I'm brain dead today.)
>From 4992557be0140c0aa4708f74fa8f9d072ee1397b Mon Sep 17 00:00:00 2001
From: Philip Reames <preames at rivosinc.com>
Date: Thu, 15 Aug 2024 14:22:24 -0700
Subject: [PATCH] [RISCV] Use significant bits helpers in narrowing of build
vectors [nfc]
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index e16dd132ed71b..515d7dbcd47bd 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -3813,16 +3813,14 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
// TODO: We really should be costing the smaller vector. There are
// profitable cases this misses.
if (EltBitSize > 8 && VT.isInteger() &&
- (NumElts <= 4 || VT.getSizeInBits() > Subtarget.getRealMinVLen())) {
- unsigned SignBits = DAG.ComputeNumSignBits(Op);
- if (EltBitSize - SignBits < 8) {
- SDValue Source = DAG.getBuildVector(VT.changeVectorElementType(MVT::i8),
- DL, Op->ops());
- Source = convertToScalableVector(ContainerVT.changeVectorElementType(MVT::i8),
- Source, DAG, Subtarget);
- SDValue Res = DAG.getNode(RISCVISD::VSEXT_VL, DL, ContainerVT, Source, Mask, VL);
- return convertFromScalableVector(VT, Res, DAG, Subtarget);
- }
+ (NumElts <= 4 || VT.getSizeInBits() > Subtarget.getRealMinVLen()) &&
+ DAG.ComputeMaxSignificantBits(Op) <= 8) {
+ SDValue Source = DAG.getBuildVector(VT.changeVectorElementType(MVT::i8),
+ DL, Op->ops());
+ Source = convertToScalableVector(ContainerVT.changeVectorElementType(MVT::i8),
+ Source, DAG, Subtarget);
+ SDValue Res = DAG.getNode(RISCVISD::VSEXT_VL, DL, ContainerVT, Source, Mask, VL);
+ return convertFromScalableVector(VT, Res, DAG, Subtarget);
}
if (SDValue Res = lowerBuildVectorViaDominantValues(Op, DAG, Subtarget))
More information about the llvm-commits
mailing list