[llvm-bugs] [Bug 27372] -f[no-]associative-math is not honored

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 1 19:27:34 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=27372

Warren Ristow <warren_ristow at playstation.sony.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #16 from Warren Ristow <warren_ristow at playstation.sony.com> ---
The main aspects of this work are now done, primarily due to Sanjay's work. For
reference, the key commits are listed below (there are other relevant commits,
but the ones listed below cover the main aspects):

  1.  Refactoring handling of fast-math-flags in the driver was done: r297837.

  2.  The umbrella aspect of the 'fast' IR flag has been removed: r317488.

  3.  The Driver and CodeGen in Clang were changed so that they no longer drop
      the '-f[no-]associative-math' switch on the floor: r320920.

  4.  Miscellaneous commits as part of the audit of transforms mentioned in
      comment 1 have been done (to examine an appropriate subset of the FMF in
      relevant places, rather than requiring the entire set): the last one for
      this PR being r330089.

More of the auditing of fast-math-related transforms remains, in that there
still are cases where disabling a portion of the FMF suppresses unrelated
fast-math transformations.  (I haven't reduced a specific example, but I've
seen cases that have reassociation opportunities (and so reassociation happens
with '-ffast-math'), and do not have any divisions, but the reassociation is
suppressed when compiled with '-ffast-math -fno-reciprocal-math'.)

In summary, with r330089, for the test-case:

  float foo(float a, float x) {
    return ((a + x) - x);
  }

reassociation is done with the following sets of flags:

  A.  -O2 -ffast-math
  B.  -O2 -ffast-math -fno-reciprocal-math
  C.  -O2 -ffast-math -fmath-errno
  D.  -O2 -fassociative-math -fno-signed-zeros -fno-trapping-math

Prior to r330089, B, C and D incorrectly suppressed the reassociation.

(Also, reassociation is correctly suppressed with:
      -O2 -ffast-math -fno-associative-math
and that has been the case since r297837.)

Even though more auditing of fast-math-related transforms remains, with the
fundamental handling of '-f[no-]associative-math' now in place, and with
the test-case shown above now working correctly with the various specified
switches, I view this issue as resolved.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180502/49e3575a/attachment.html>


More information about the llvm-bugs mailing list