[llvm-bugs] [Bug 29009] New: Redundent and instruction caused by switch condition operand shrinking

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 16 16:58:28 PDT 2016


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

            Bug ID: 29009
           Summary: Redundent and instruction caused by switch condition
                    operand shrinking
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: wmi at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16969
  --> https://llvm.org/bugs/attachment.cgi?id=16969&action=edit
testcase 1.cc

For the testcase 1.cc attached.

~/workarea/llvm-r278451/dbuild/bin/clang -O2 -S 1.cc

Here is the code to generate the index to access jump table:

        movl    njob(%rip), %eax
        callq   _Z3goov
        movl    %eax, %edx
        andb    $7, %dl
        movl    %eax, %ecx
        andl    $7, %ecx     // There is redundency to compute "and $7, ..."
twice.
        cmpb    $7, %dl
        je      .LBB0_3
# BB#2:                                 # %while.cond
                                        #   in Loop: Header=BB0_1 Depth=1
        jmpq    *.LJTI0_0(,%rcx,8)

Better code is:
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        movl    njob(%rip), %eax
        callq   _Z3goov
        movl    %eax, %ecx
        andl    $7, %ecx
        cmpl    $6, %ecx
        ja      .LBB0_3
# BB#2:                                 #   in Loop: Header=BB0_1 Depth=1
        jmpq    *.LJTI0_0(,%rcx,8)

Looks like it is caused by r274233 which allows illegal type generated when
shrinking switch condition operand.

-- 
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/20160816/19a036ab/attachment.html>


More information about the llvm-bugs mailing list