[llvm] [InstCombine] Fix for folding `select` into floating point binary operators. (PR #83200)

Paul Osmialowski via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 12:07:25 PDT 2024


pawosm-arm wrote:

If I add the `fast` attribute to the `select` in my example code:
```
  %cmp1 = fcmp fast ogt double %sub, 0.000000e+00
  %add1 = select nsz i1 %cmp1, double %sub, double 0.000000e+00
  %v1.1 = fadd fast double %add1, %v1
```
the transformation succeed even with your patch. It's because of this:
```
    // TODO: We probably ought to revisit cases where the select and FP
    // instructions have different flags and add tests to ensure the
    // behaviour is correct.
    FastMathFlags FMF;
    if (isa<FPMathOperator>(&SI))
      FMF = SI.getFastMathFlags();
```
`select` isn't fast but other things are, so we hit the `TODO:` situation.


https://github.com/llvm/llvm-project/pull/83200


More information about the llvm-commits mailing list