[llvm] [RISCV] Narrow vector absolute value (PR #82041)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 13:27:05 PST 2024
================
@@ -15611,6 +15611,19 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
return DAG.getNode(ISD::AND, DL, VT, NewFMV,
DAG.getConstant(~SignBit, DL, VT));
}
+ case ISD::ABS: {
+ EVT VT = N->getValueType(0);
+ SDValue N0 = N->getOperand(0);
+ // abs (sext) -> sext (abs)
----------------
topperc wrote:
Shouldn't this be abs(sext) -> zext(abs)?
InstCombine
```
// abs (sext X) --> zext (abs X*)
// Clear the IsIntMin (nsw) bit on the abs to allow narrowing.
if (match(IIOperand, m_OneUse(m_SExt(m_Value(X))))) {
Value *NarrowAbs =
Builder.CreateBinaryIntrinsic(Intrinsic::abs, X, Builder.getFalse());
return CastInst::Create(Instruction::ZExt, NarrowAbs, II->getType());
}
```
https://github.com/llvm/llvm-project/pull/82041
More information about the llvm-commits
mailing list