[llvm] [RISCV] Lower (select c, y, 0) -> (qc.muliadd c, y-1) (PR #190323)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 14:32:24 PDT 2026
================
@@ -9663,8 +9663,14 @@ static SDValue lowerSelectToBinOp(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(ISD::AND, DL, VT, Neg, DAG.getFreeze(FalseV));
}
if (isNullConstant(FalseV)) {
- // (select c, (1 << ShAmount) + 1, 0) -> (c << ShAmount) + c
if (auto *TrueC = dyn_cast<ConstantSDNode>(TrueV)) {
+ // (select c, y, 0) -> (c * (y - 1)) + c
+ int64_t TrueM2 = TrueC->getSExtValue() - 1;
----------------
topperc wrote:
If TrueC is INT64_MIN, this has signed overflow which would fail if the compiler was built with UBSAN. Since the code is before the check for hasVendorXqciac we can't rely on the type being i32 to protect it.
https://github.com/llvm/llvm-project/pull/190323
More information about the llvm-commits
mailing list