[llvm] 2b0b85c - [RISCV] Move vector handling earlier in lowerSELECT. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 15 22:36:53 PDT 2023
Author: Craig Topper
Date: 2023-07-15T22:34:19-07:00
New Revision: 2b0b85c05e74afa395f4250e1bff7ce6a51917af
URL: https://github.com/llvm/llvm-project/commit/2b0b85c05e74afa395f4250e1bff7ce6a51917af
DIFF: https://github.com/llvm/llvm-project/commit/2b0b85c05e74afa395f4250e1bff7ce6a51917af.diff
LOG: [RISCV] Move vector handling earlier in lowerSELECT. NFC
This keeps all the scalar code together.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index e15626cc81ccac..32752789f982a6 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -5893,6 +5893,13 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
MVT VT = Op.getSimpleValueType();
MVT XLenVT = Subtarget.getXLenVT();
+ // Lower vector SELECTs to VSELECTs by splatting the condition.
+ if (VT.isVector()) {
+ MVT SplatCondVT = VT.changeVectorElementType(MVT::i1);
+ SDValue CondSplat = DAG.getSplat(SplatCondVT, DL, CondV);
+ return DAG.getNode(ISD::VSELECT, DL, VT, CondSplat, TrueV, FalseV);
+ }
+
// When Zicond is present, emit CZERO_EQZ and CZERO_NEZ nodes to implement
// the SELECT. Performing the lowering here allows for greater control over
// when CZERO_{EQZ/NEZ} are used vs another branchless sequence or
@@ -5955,13 +5962,6 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
DAG.getNode(RISCVISD::CZERO_NEZ, DL, VT, FalseV, CondV));
}
- // Lower vector SELECTs to VSELECTs by splatting the condition.
- if (VT.isVector()) {
- MVT SplatCondVT = VT.changeVectorElementType(MVT::i1);
- SDValue CondSplat = DAG.getSplat(SplatCondVT, DL, CondV);
- return DAG.getNode(ISD::VSELECT, DL, VT, CondSplat, TrueV, FalseV);
- }
-
if (SDValue V = combineSelectToBinOp(Op.getNode(), DAG, Subtarget))
return V;
More information about the llvm-commits
mailing list