[PATCH] D132252: [RISCV] Optimize x <s -1 ? x : -1. Improve x >u 1 ? x : 1.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 10:44:16 PDT 2022
craig.topper added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:4025
// x > 1 ? x : 1 -> x > 0 ? x : 1
- if (isOneConstant(LHS) && !isa<ConstantSDNode>(RHS) &&
- (CCVal == ISD::SETLT || CCVal == ISD::SETULT) && RHS == TrueV &&
- isOneConstant(FalseV)) {
+ if (isOneConstant(LHS) && (CCVal == ISD::SETLT || CCVal == ISD::SETULT) &&
+ RHS == TrueV && LHS == FalseV) {
----------------
I dropped the non-constant RHS check here because it doesn't matter for the correctness of the combine and an all constant setcc should have been DAG combined away.
================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:4026
+ if (isOneConstant(LHS) && (CCVal == ISD::SETLT || CCVal == ISD::SETULT) &&
+ RHS == TrueV && LHS == FalseV) {
LHS = DAG.getConstant(0, DL, VT);
----------------
Remove the second call to isOneConstant by checking if LHS == FalseV since we already know LHS is 1. These two changes improve the similarity with the new combine introduced here.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132252/new/
https://reviews.llvm.org/D132252
More information about the llvm-commits
mailing list