[llvm-bugs] [Bug 32755] New: Improvement Oppurtunity in CodeGen instruction Selection

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 23 06:53:11 PDT 2017


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

            Bug ID: 32755
           Summary: Improvement Oppurtunity in CodeGen instruction
                    Selection
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lama.saba at intel.com
                CC: llvm-bugs at lists.llvm.org

for the following IR code

{code}
 define void @foo(%struct.SA* nocapture %ctx, i32 %n) local_unnamed_addr #0 {
 entry:
   %h0 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 0
   %0 = load i32, i32* %h0, align 8, !tbaa !1
   %h3 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 3
   %h4 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 4
   %1 = load i32, i32* %h4, align 8, !tbaa !7
   %add = add i32 %0, 1
   %add4 = add i32 %add, %1
   store i32 %add4, i32* %h3, align 4, !tbaa !8
   %add29 = add i32 %add4, %1
   store i32 %add29, i32* %h4, align 8, !tbaa !7
   ret void
 }

{code}

The generated code  from Clang  with command llc  test.ll  -o  :
{code}
 # BB#0:                                 # %entry
     movl    (%rdi), %eax
     movl    16(%rdi), %ecx
     leal    (%rax,%rcx), %edx
     leal    1(%rax,%rcx), %eax
     movl    %eax, 12(%rdi)
     leal    1(%rcx,%rdx), %eax
     movl    %eax, 16(%rdi)
     retq
{code}

It can be generated as:
{code}
     # BB#0:                                 # %entry
     movl    (%rdi), %eax
     movl    16(%rdi), %ecx
     leal    1(%rax,%rcx), %eax
     movl    %eax, 12(%rdi)
     lea       (%ecx,%eax), %newReg
     movl    %newReg, 16(%rdi)
     retq
{code}

which avoids expensive lea instructions.
Instruction selection generates an ADD instruction which later gets replaced by
leal    (%rax,%rcx), %edx (by the RA)

-- 
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/20170423/b8bbb8fe/attachment.html>


More information about the llvm-bugs mailing list