[PATCH] D57921: [DAG] Cleanup unused node in SimplifySelectCC.
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 08:14:46 PDT 2019
RKSimon added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:18677
SDValue SCC = SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
false);
+ if (SCC.getNode()) {
----------------
RKSimon wrote:
> RKSimon wrote:
> > Could we replace this with a call to SelectionDAG::FoldSetCC()? That should only ever constant fold which AFAICT is what we're after.
> Actually it looks like there's a tiny bit of commutation code (moves single constant to RHS) that probably needs pulling out of FoldSetCC into getNode - but that's trivial compared to the TLI.SimplifySetCC monster.
Confirmed, this gives the same result and is a lot cleaner:
```
// Determine if the condition we're dealing with is constant.
if (SDValue SCC = DAG.FoldSetCC(VT, N0, N1, CC, DL)) {
if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC)) {
// fold select_cc true, x, y -> x
// fold select_cc false, x, y -> y
return !SCCC->isNullValue() ? N2 : N3;
}
}
```
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57921/new/
https://reviews.llvm.org/D57921
More information about the llvm-commits
mailing list