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

            Bug ID: 116576
           Summary: `INT64_MAX` and `-Oz`
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

For this simple function:

   ```
   int64_t make_value(void) { return INT64_MAX; }
   ```

Both GCC and Clang generate an 8-byte `movabs` which adds up to 10 bytes:

   ```
   48 b8 ffffffffffffff7f    ; mov rax, 0x7fffffffffffffff
                             ; (10 bytes; no dependency)
   ```

When we do `-Oz` we otpimize for size and do not care about the false
dependency, and this can be accomplished in only 7 bytes:

   ```
   48 83 c8 ff               ; or rax, -1
   48 d1 e8                  ; shr rax
                             ; (7 bytes; input dependency on rax)
   ```

Reply via email to