[LLVMbugs] [Bug 10062] New: llvm doesn't merge masked loads

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 1 15:38:06 PDT 2011


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

           Summary: llvm doesn't merge masked loads
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, scshunt at csclub.uwaterloo.ca


This is related to bug 5039 but is specifically concerned with cases where LLVM
should be able to merge the loads/tests across multiple fields. A patch in
development would put this sort of optimizable logic in clang's hot path, so we
took a look at what sort of code LLVM would generate for it. Testcase:

  struct Foo {
    unsigned char foo : 5;
    unsigned char bar : 3;
  };

  int test1(struct Foo foo) {
    // should be a single comparison
    return foo.foo == 3 && foo.bar == 3;
  }

  int test2(struct Foo foo) {
    // should be a single comparison
    return foo.foo != 0 || foo.bar != 0;
  }

  int test3(struct Foo foo) {
    // should be a single cast
    return foo.bar + (foo.foo << 3);
  }

test1 has an entire branch which looks like the same problem as bug 10054.
test2 and test3 are straight-line code with no optimization opportunities taken
advantage of.

For reference, GCC 4.6 produces:

test1:
        xorl    %eax, %eax
        cmpb    $99, %dil
        sete    %al
        ret

test2:
        xorl    %eax, %eax
        testb   %dil, %dil
        setne   %al
        ret

test3:
        movl    %edi, %eax
        andl    $31, %edi
        shrb    $5, %al
        movzbl  %al, %eax
        leal    (%rax,%rdi,8), %eax
        ret

with a missed optimization in test3.

-- 
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