[llvm] [DAG] Fixing the non-optimal code with the following: `select i1 %0, float 1.0, float 0.0`. (PR #107732)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 21:01:13 PDT 2024
c8ef wrote:
https://github.com/llvm/llvm-project/blob/caebb4562ce634a22f7b13480b19cffc2a6a6730/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L17953-L17959
It seems that when applying this patch, we are switching back and forth between `select` and `uint_to_fp`.
```
// fold (uint_to_fp (setcc x, y, cc)) -> (select (setcc x, y, cc), 1.0, 0.0)
if (N0.getOpcode() == ISD::SETCC && !VT.isVector() &&
(!LegalOperations || TLI.isOperationLegalOrCustom(ISD::ConstantFP, VT))) {
SDLoc DL(N);
return DAG.getSelect(DL, VT, N0, DAG.getConstantFP(1.0, DL, VT),
DAG.getConstantFP(0.0, DL, VT));
}
```
https://github.com/llvm/llvm-project/pull/107732
More information about the llvm-commits
mailing list