[LLVMbugs] [Bug 9803] New: Code uses movl 0, reg instead of xor reg, reg

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 27 19:38:01 PDT 2011


           Summary: Code uses movl 0, reg instead of xor reg, reg
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jmuizelaar at mozilla.com
                CC: llvmbugs at cs.uiuc.edu

int clamp2(int a)
        if (a > 5) {
                a = 5;
        if (a < 0) {
                return 0;
        } else {
                return a;

The code above compiles with -Os to:

_clamp2:                                ## @clamp2
        pushq   %rbp
        movq    %rsp, %rbp
        cmpl    $5, %edi
        movl    $5, %ecx
        cmovlel %edi, %ecx
        testl   %ecx, %ecx
        movl    $0, %eax
---------^ this can be xorl, %eax, %eax to save space
        cmovnsl %ecx, %eax
        popq    %rbp

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