[PATCH] D129757: [RISCV] Optimize SELECT_CC when the true value of select is Constant

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 09:20:11 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:3900
+          DAG.getCondCode(ISD::getSetCCInverse(CCVal, LHS.getValueType()));
+      SDValue Ops[] = {LHS, RHS, TargetCC, FalseV, TrueV};
+      return DAG.getNode(RISCVISD::SELECT_CC, DL, Op.getValueType(), Ops);
----------------
liaolucy wrote:
> jrtc27 wrote:
> > frasercrmck wrote:
> > > Could we instead just `std::swap(TrueV, FalseV)` and let it fall through? I think that's clearer to read.
> > This still isn't falling through. Ops and the return are identical to outside the if, you can just reuse them.
> I'll update it back later.
> SDValue Ops[] = {LHS, RHS, TargetCC, FalseV, TrueV,};
This is still not the addressing the comment. This was the request

```
    if (isa<ConstantSDNode>(TrueV) && !isa<ConstantSDNode>(FalseV)) {
      std::swap(TrueV, FalseV)
      TargetCC =
          DAG.getCondCode(ISD::getSetCCInverse(CCVal, LHS.getValueType()));
    }

    SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV};
    return DAG.getNode(RISCVISD::SELECT_CC, DL, Op.getValueType(), Ops);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129757/new/

https://reviews.llvm.org/D129757



More information about the llvm-commits mailing list