This allows us to fold fma's that multiply with 0.0. Also, the
multiply by 1.0 case is handled there as well. The fneg/fabs cases
are not handled by SimplifyFMulInst, so we need to keep them.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | ||
---|---|---|
2247–2252 ↗ | (On Diff #219329) | I don't understand what this block does. How does an fmul simplify to a different fmul? And then it becomes LHS^2? |
2260–2262 ↗ | (On Diff #219329) | It would be easier to read if you move the simplify call below these local variables and then re-use those names. |
llvm/test/Transforms/InstCombine/fma.ll | ||
185 ↗ | (On Diff #219329) | I'm not seeing how these got commuted. |
372–375 ↗ | (On Diff #219329) | Please add all of the new tests with baseline results as a preliminary commit, so we just have the diffs here. |
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | ||
---|---|---|
2247–2252 ↗ | (On Diff #219329) |
If we simplify to a different fmul, we can update the existing FMA and we do not have to replace it with a new fmul + fadd. Not sure if that happens in practice though. Simplifications like the ones below ( -x * -y => x * y) could result in a different fmul. But currently we do not do this in SimplifyFMulInst. If there is a reason we never do create different fmuls there, then we can drop it.
That should have been RHS of course. |
2260–2262 ↗ | (On Diff #219329) | Sure, I've moved it down. |
llvm/test/Transforms/InstCombine/fma.ll | ||
185 ↗ | (On Diff #219329) | That was noise of update_test_checks.py I think. The way it generates checks for arguments, it will match both fmul %x, %y and fmul %y, %x. I've stripped the unnecessary changes. |
372–375 ↗ | (On Diff #219329) | Done |
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | ||
---|---|---|
2247–2252 ↗ | (On Diff #219329) | I think we should drop this clause...unless there is a test that shows the intended transform? // -X * -Y --> X * Y (can't do that in instsimplify because it's a new instruction) |
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | ||
---|---|---|
2247–2252 ↗ | (On Diff #219329) | Thanks for clarifying! I've dropped it. |