[llvm-bugs] [Bug 42456] New: [InstCombine] Dropping pointless masking before shift

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 30 11:40:05 PDT 2019


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

            Bug ID: 42456
           Summary: [InstCombine] Dropping pointless masking before shift
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/z/cuuf0P
https://rise4fun.com/Alive/PcZk

int bad(unsigned input, unsigned len) {
    unsigned shamt = (32 - len);
    unsigned diff = input >> shamt;
    return (int(diff) << shamt) >> shamt;
}
int good(unsigned input, unsigned len) {
    return int(input) >> (32 - len);
}

Name: 
  %sub = sub i32 32, %len
  %zz = shl i32 -1, %sub
  %shl = and i32 %zz, %input
  %r = ashr i32 %shl, %sub
=>
  %r = ashr i32 %input, %sub

-- 
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/20190630/4ab7f344/attachment.html>


More information about the llvm-bugs mailing list