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

            Bug ID: 42399
           Summary: InstCombine: shift amount reassociation when doing bit
                    test
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

https://godbolt.org/z/Kq82aC
https://rise4fun.com/Alive/kBb

bool bad(unsigned x, unsigned y, unsigned skip0, unsigned skip1) {
    x >>= skip0;
    return x & (y << skip1);
}
bool good(unsigned x, unsigned y, unsigned skip0, unsigned skip1) {
    return x & (y << (skip1+skip0));
}

Name: 
Pre: C1+C2 u< 32
%o4 = lshr i32 %x, C1
%o5 = shl i32 %y, C2
%o6 = and i32 %o5, %o4
%r = icmp ne i32 %o6, 0
  =>
%n4 = add i32 C1, C2
%n5 = shl i32 %y, %n4
%n6 = and i32 %n5, %x
%r = icmp ne i32 %n6, 0


Still from real code..

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to