[Bug middle-end/84996] New: Adding or substracting 0.0 could be optimized away even without -ffast-math

antoshkka at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Mar 20 16:35:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84996

            Bug ID: 84996
           Summary: Adding or substracting 0.0 could be optimized away
                    even without -ffast-math
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

The code 

float test(float lhs) { return lhs + 0.0; }

generates suboptimal assembly

test(float):
        addss   xmm0, DWORD PTR .LC0[rip]
        ret
.LC0:
        .long   0



Optimal assembly would be 

test(float): # @test(float)
  ret


More information about the Gcc-bugs mailing list