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

            Bug ID: 91409
           Summary: Missed optimization on `labels as values` expression
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mserdarsanli at gmail dot com
  Target Milestone: ---

I recently posted about this on SO, but it did not gain much traction:
https://stackoverflow.com/questions/55987401/gcc-clang-labels-as-values-computing-offsets-at-runtime

The missed optimization is when using `labels as values` feature and computing
address difference. The expression `&&label2 - &&label1` generates code that
does the subtraction on runtime, while it might be possible to compute it on
compile time.

Godbolt link: https://godbolt.org/z/zZdFYo

Reply via email to