Patterns that were folded into fabs in DAGCombiner with the no-NaNs fast-math flag were semantically incorrect, as they should actually produce -0.0 on one of the zero inputs. This patch adds a no-signed-zeros check around those patterns as well as additional sign-of-zero compliant patterns that do not require this check.
Diff Detail
Event Timeline
I fixed the test file to check all output here:
rL326735
Use the script to auto-generate check lines for any tests that you are adding.
Please rebase and upload the patch with full context:
https://llvm.org/docs/Phabricator.html#phabricator-request-review-web
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
16964 | We're checking the flags on a node, but there is no regression test with 'nsz' FMF on the IR? | |
16982–16983 | Use 'auto' with 'dyn_cast': ...although what happens with vector types? Are they handled on a different path? |
Rebased and reuploaded with full context. Added code to propagate nsz from IR to DAG for the fneg node, as well as to retain flags during vector type legalization. Added tests for flag use on nodes and for vector type fabs folding.
Added TargetOptions checks to get nsz from function attributes. Added a test case for that.
What do you think of my suggestion from D44550 - can we just remove this code from SDAG now that we canonicalize the IR?
I agree with this, and I think it should be a new revision rather that this one. If you agree, I'll declare this one abandoned and leave it as is, then make a new one that just removes the buggy code from DAGCombiner.
We're checking the flags on a node, but there is no regression test with 'nsz' FMF on the IR?