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

            Bug ID: 95834
           Summary: x86 immediates --- some redundant
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zero at smallinteger dot com
  Target Milestone: ---

Created attachment 48774
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48774&action=edit
sample code

In some cases, literals could be synthesized with simple instructions instead
of loading them from scratch.  Consider the case of foo(), with 4 literals that
can be obtained by shifting the first one: gcc emit 5 eight-byte literals
instead.

In some other cases, the same literals are loaded.  Consider the case of baz(),
where 6 is loaded twice in consecutive instructions when an instruction reorder
could eliminate one of the literals.

The Intel optimization manual suggests not to have many instructions that load
literals in a row due to decreased code density, more difficulty to cache the
decoded instructions due to lack of space, and because shorter instruction
encodings are better.

Verified with gcc 9.3.0 and gcc 10.x (at godbolt), with -O3.

Reply via email to