If the accumulator and either of the multiply operands are negateable then we can we negate the entire expression.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
LGTM. Does everything still pass if you delete the FMA/FMAD case in AMDGPUTargetLowering::performFNegCombine?
Thanks for pointing that out - it made me realise there's an issue in that we're not checking for UnsafeMath/hasNoSignedZeros like we do for FADD.
Updated patch to correctly respect NSZ flags. I've also improved the logic to ensure we negate the most profitable multiplication factor, not just the first one.
Once this is in place, the plan is to start work on https://bugs.llvm.org/show_bug.cgi?id=42863 so we can hook this into propagating negation through target opcodes as well.
The problem we currently have is that AMDGPUTargetLowering::performFNegCombine allows multiple uses of the FMA/FMAD but the DAGCombine doesn't, so I'm going to suggest we wait until PR42863 to handle that.