[PATCH] D146117: [RISCV]Optimize (riscvisd::select_cc x, 0, ne, x, 1)
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 15 08:56:32 PDT 2023
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:10914
}
+ // (riscvisd::select_cc x, 0, ne, x, 1) -> (add x, (setcc x, 0, eq))
+ if (isNullConstant(RHS) && isOneConstant(FalseV) && LHS == TrueV &&
----------------
We need to handle the commuted case `iscvisd::select_cc x, 0, eq, 1, x` as well.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:10917
+ CCVal == ISD::CondCode::SETNE) {
+ SDValue C = DAG.getSetCC(DL, VT, LHS, RHS, ISD::CondCode::SETEQ);
+ return DAG.getNode(ISD::ADD, DL, VT, LHS, C);
----------------
I think you need to do
`LHS = DAG.getFreeze(LHS);`
to make this safe for undefined values.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146117/new/
https://reviews.llvm.org/D146117
More information about the llvm-commits
mailing list