This is an archive of the discontinued LLVM Phabricator instance.

[DAG] use SDNode flags 'nsz' to enable fadd/fsub with zero folds
ClosedPublic

Authored by spatel on Oct 5 2016, 5:02 PM.

Details

Summary

As discussed in D24815, let's start the process of killing off the broken fast-math global state housed in TargetOptions and eliminate the need for function-level fast-math attributes.

Looks like I started this mission in D9708...and promptly got distracted for almost a year. :)

Here we enable two similar folds that are possible when we don't care about signed-zero:
fadd nsz x, 0 --> x
fsub nsz 0, x --> -x

Note that although the test cases include a 'sin' function call, I'm side-stepping the FMF-on-calls question (and lack of support in the DAG) for now. It's not needed for these tests - isNegatibleForFree/GetNegatedExpression just look through a ISD::FSIN node.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 73711.Oct 5 2016, 5:02 PM
spatel retitled this revision from to [DAG] use SDNode flags 'nsz' to enable fadd/fsub with zero folds.
spatel updated this object.
spatel added reviewers: mehdi_amini, echristo, hfinkel.
spatel added a subscriber: llvm-commits.
RKSimon added a subscriber: RKSimon.Oct 6 2016, 3:01 PM
echristo accepted this revision.Oct 20 2016, 1:41 PM
echristo edited edge metadata.

This seems reasonable to me. I'd like to see something that adds the attribute to the instructions at some point, but as an intermediate step this is fine.

-eric

This revision is now accepted and ready to land.Oct 20 2016, 1:41 PM

This seems reasonable to me. I'd like to see something that adds the attribute to the instructions at some point, but as an intermediate step this is fine.

Do you mean propagate the FMF flags on the returned SDNode? Eg:

return DAG.getNode(ISD::FNEG, DL, VT, N1, Flags);

Oops...I forgot to do that in *this* patch.

This seems reasonable to me. I'd like to see something that adds the attribute to the instructions at some point, but as an intermediate step this is fine.

Do you mean propagate the FMF flags on the returned SDNode? Eg:

return DAG.getNode(ISD::FNEG, DL, VT, N1, Flags);

Oops...I forgot to do that in *this* patch.

Although in my defense, putting the Flags on an FNEG is an academic exercise at this point because we only have FMF on binary SDNodes. The flags will be dropped in getNode() for the unary node.

*nod* I'm not worried about it.

-eric

This revision was automatically updated to reflect the committed changes.