This is an archive of the discontinued LLVM Phabricator instance.

move IR-level optimization flags into their own struct
ClosedPublic

Authored by spatel on Apr 28 2015, 9:05 AM.

Details

Summary

This is a preliminary step to using the IR-level floating-point fast-math-flags in the SDAG (D8900).

In this patch, we introduce the optimization flags as their own struct. As noted in the TODO comment, we should eventually share this data between the IR passes and the backend.

We also switch the existing nsw / nuw / exact bit functionality of the BinaryWithFlagsSDNode class to use the new struct.

The tradeoff is that instead of using the free but limited space of SDNode's SubclassData, we add a data member to the subclass. This means we don't have to repeat all of the get/set methods per flag, but we're potentially adding size to all nodes of this subclass.

In practice on 64-bit systems (measured on Linux and MacOS X), there is no size difference between an SDNode and BinaryWithFlagsSDNode after this change: they're both 80 bytes. This means that we had at least one free byte to play with due to struct alignment.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 24554.Apr 28 2015, 9:05 AM
spatel retitled this revision from to move IR-level optimization flags into their own struct.
spatel updated this object.
spatel edited the test plan for this revision. (Show Details)
spatel added reviewers: echristo, hfinkel, kariddi, andreadb.
spatel added subscribers: alexr, resistor, ab, Unknown Object (MLST).
echristo accepted this revision.Apr 28 2015, 9:14 AM
echristo edited edge metadata.

Other than the one comment LGTM.

Thanks!

-eric

include/llvm/CodeGen/SelectionDAGNodes.h
932–988 ↗(On Diff #24554)

I know where you're going with this formatting, but I don't know that it really enhances readability any more than just clang formatting it and not worrying about it.

This revision is now accepted and ready to land.Apr 28 2015, 9:14 AM
spatel added inline comments.Apr 28 2015, 9:21 AM
include/llvm/CodeGen/SelectionDAGNodes.h
932–988 ↗(On Diff #24554)

Ok - clang-format would just wrap at 80-cols:

unsigned getRawFlags() const {
  return (NoUnsignedWrap << 0) | (NoSignedWrap << 1) | (Exact << 2) |
         (UnsafeAlgebra << 3) | (NoNaNs << 4) | (NoInfs << 5) |
         (NoSignedZeros << 6) | (AllowReciprocal << 7);
}
spatel added inline comments.Apr 28 2015, 9:27 AM
include/llvm/CodeGen/SelectionDAGNodes.h
932–988 ↗(On Diff #24554)

Ah, sorry - you're also referencing the added spaces above this. Yep, clang-format will raggify all of that. Seems less beautiful to me, but ok. :)

This revision was automatically updated to reflect the committed changes.