Skip to content

Commit b67a9ba

Browse files
committed
[RISCV] Add TargetLowering::hasConditionalZero()
Will guide lowering chioces in DAGCombine.
1 parent a10ddf7 commit b67a9ba

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,10 @@ class LLVM_ABI TargetLoweringBase {
25022502
Action != TypeSplitVector;
25032503
}
25042504

2505+
// Return true is targets has a conditional zero-ing instruction
2506+
// i.e. select cond, x, 0
2507+
virtual bool hasConditionalZero() const { return false; }
2508+
25052509
virtual bool isProfitableToCombineMinNumMaxNum(EVT VT) const { return true; }
25062510

25072511
/// Return true if a select of constants (select Cond, C1, C2) should be

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,6 +2763,10 @@ bool RISCVTargetLowering::mergeStoresAfterLegalization(EVT VT) const {
27632763
(VT.isFixedLengthVector() && VT.getVectorElementType() == MVT::i1);
27642764
}
27652765

2766+
bool RISCVTargetLowering::hasConditionalZero() const {
2767+
return Subtarget.hasStdExtZicond() || Subtarget.hasVendorXVentanaCondOps();
2768+
}
2769+
27662770
bool RISCVTargetLowering::isLegalElementTypeForRVV(EVT ScalarTy) const {
27672771
if (!ScalarTy.isSimple())
27682772
return false;

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ class RISCVTargetLowering : public TargetLowering {
612612
return false;
613613
}
614614

615+
bool hasConditionalZero() const override;
616+
615617
/// Disables storing and loading vectors by default when there are function
616618
/// calls between the load and store, since these are more expensive than just
617619
/// using scalars

0 commit comments

Comments
 (0)