[LLVMbugs] [Bug 7036] New: Redundant "andl $1, %eax" instruction

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 4 01:01:44 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7036

           Summary: Redundant "andl $1, %eax" instruction
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: mdevan.foobar at gmail.com
                CC: llvmbugs at cs.uiuc.edu


[Linux/amd64, LLVM r100854]

LLVM seems to like adding a redundant "andl $1, %eax" instruction in the code
generated (via clang) for the C code:

------------------------------------------------------------

extern int f();
int test(int a) { return a && f(); }

------------------------------------------------------------

define i32 @test(i32 %a) nounwind {
entry:
  %tobool = icmp eq i32 %a, 0                     ; <i1> [#uses=1]
  br i1 %tobool, label %land.end, label %land.rhs

land.rhs:                                         ; preds = %entry
  %call = tail call i32 (...)* @f() nounwind      ; <i32> [#uses=1]
  %tobool1 = icmp ne i32 %call, 0                 ; <i1> [#uses=1]
  br label %land.end

land.end:                                         ; preds = %entry, %land.rhs
  %0 = phi i1 [ false, %entry ], [ %tobool1, %land.rhs ] ; <i1> [#uses=1]
  %land.ext = zext i1 %0 to i32                   ; <i32> [#uses=1]
  ret i32 %land.ext
}

------------------------------------------------------------

test:
.Leh_func_begin1:
        pushq   %rbp
.Ltmp0:
        movq    %rsp, %rbp
.Ltmp1:
        testl   %edi, %edi
        jne     .LBB1_2
        xorb    %al, %al
        jmp     .LBB1_3
.LBB1_2:
        xorb    %al, %al
        callq   f
        testl   %eax, %eax
        setne   %al
.LBB1_3:
        movzbl  %al, %eax
        andl    $1, %eax
        popq    %rbp
        ret

------------------------------------------------------------

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list