This patch originated from D46562 and is a proper subset, with some issues addressed for fmul.
Details
Diff Detail
Event Timeline
test/CodeGen/X86/fp-fold.ll | ||
---|---|---|
104 | Can remove the TODO now. |
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
724–726 | Hang on - I missed this change. Why does this require nsz? |
Hmm...how does NaN change anything?
Instcombine moves fneg without any FMF:
// Sink negation: -X * Y --> -(X * Y)
So Options.HonorSignDependentRoundingFPMath is sufficient to guard fmul negate and we can drop the unsafe context, is that only true for multiply? What about divide?
I've never looked at HonorSignDependentRoundingFPMath:
/// If this is enabled (set to true), the code generator must /// assume that the rounding mode may dynamically change.
That would seem to preclude a bunch of transforms, but I don't know why that's guarding this particular transform.
We need to split this diff into its own patch and find the existing tests and/or add new tests, so we know what's going on here.
fmul and fdiv should be treated the same with regard to fneg transforms (although instcombine probably gets this wrong).
Hang on - I missed this change. Why does this require nsz?