[llvm-bugs] [Bug 26330] New: [x86] Unnecessary materialization of call argument

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 26 14:46:56 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26330

            Bug ID: 26330
           Summary: [x86] Unnecessary materialization of call argument
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvm-bugs at lists.llvm.org
            Blocks: 26299
    Classification: Unclassified

When pushing arguments to a function call, constant arguments can go as
immediates in the push instructions:

  void f(int, int);
  void g() {
    f(0, 5); 
  }

00000000 <?g@@YAXXZ>:
   0:    6a 05                    push   $0x5
   2:    6a 00                    push   $0x0
   4:    e8 00 00 00 00           call   9 <?g@@YAXXZ+0x9>
   9:    83 c4 08                 add    $0x8,%esp
   c:    c3                       ret

But it seems that if the same value is used more than once, we materialize it
in a register:

  void g() {
    f(5, 5); 
  }

00000000 <?g@@YAXXZ>:
   0:    b8 05 00 00 00           mov    $0x5,%eax
   5:    50                       push   %eax
   6:    50                       push   %eax
   7:    e8 00 00 00 00           call   c <?g@@YAXXZ+0xc>
   c:    83 c4 08                 add    $0x8,%esp
   f:    c3

The savings on smaller push instructions is offset by the mov instruction.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160126/46d495f6/attachment.html>


More information about the llvm-bugs mailing list