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

            Bug ID: 118570
           Summary: -O2 much faster than -O3 for Romberg's method
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 60215
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60215&action=edit
rom3.c

This came up in #gcc on libera where trn reported an oddity, where -O2 is
significantly faster than -O3:
```
$ gcc -O2 rom3.c -o rom3 -lm && time ./rom3
rom3.c: In function ‘romberg’:
rom3.c:33:1: warning: old-style function definition [-Wold-style-definition]
   33 | romberg(a, b, acc)
      | ^~~~~~~
9558673.398323269560933

real    0m0.008s
user    0m0.002s
sys     0m0.006s

$ gcc -O3 rom3.c -o rom3 -lm && time ./rom3
rom3.c: In function ‘romberg’:
rom3.c:33:1: warning: old-style function definition [-Wold-style-definition]
   33 | romberg(a, b, acc)
      | ^~~~~~~
9558673.398323269560933

real    0m1.674s
user    0m1.658s
sys     0m0.004s
```

This is with recent trnuk but I see it on older releases too. -O3 -fno-ipa-cp
gives the same performance as -O2.

Reply via email to