[LLVMbugs] [Bug 23098] New: Less efficient encoding of shl using direct object emission

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 1 09:56:06 PDT 2015


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

            Bug ID: 23098
           Summary: Less efficient encoding of shl using direct object
                    emission
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: MC
          Assignee: unassignedbugs at nondot.org
          Reporter: russell_gallop at sn.scee.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

For the following source a less efficient instruction encoding is generated for
direct object emission than outputting asm (with -via-file-asm). Using r232944.

This is the case as -O0/-O1/-O2/-O3.

$ cat test.c
int a;
void fn1() { a = a << 1 & 255; }

$ clang -c test.c -O3 -o test.o && objdump -d test.o
test.o:     file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <fn1>:
   0:   8b 05 00 00 00 00       mov    0x0(%rip),%eax        # 6 <fn1+0x6>
   6:   83 e0 7f                and    $0x7f,%eax
   9:   c1 e0 01                shl    $0x1,%eax
   c:   89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 12 <fn1+0x12>
  12:   c3                      retq

$ clang -c test.c -O3 -via-file-asm -o tests.o && objdump -d tests.o
tests.o:     file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <fn1>:
   0:   8b 05 00 00 00 00       mov    0x0(%rip),%eax        # 6 <fn1+0x6>
   6:   83 e0 7f                and    $0x7f,%eax
   9:   d1 e0                   shl    %eax
   b:   89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 11 <fn1+0x11>
  11:   c3                      retq

-- 
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/20150401/7b72f96c/attachment.html>


More information about the llvm-bugs mailing list