[llvm-bugs] [Bug 42391] New: InstCombine: shift amount reassociation

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 25 13:43:00 PDT 2019


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

            Bug ID: 42391
           Summary: InstCombine: shift amount reassociation
           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/S9Zn-y
https://rise4fun.com/Alive/plLm

int bad2(unsigned diff, unsigned len1, unsigned len2) {
    return ((diff >> (32-len1)) >> (len1 - 1));
}
int good2(unsigned diff, unsigned len1, unsigned len2) {
    return diff >> ((32-len1)+(len1-1));
}

Name: dd
Pre: C > 0 ; signed positive
  %4 = sub i32 32, %1
  %5 = lshr i32 %0, %4
  %6 = sub i32 %1, C
  %r = lshr i32 %5, %6
  =>
  %z4 = sub i32 32, C
  %r = lshr i32 %0, %z4

-- 
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/20190625/b2a6148e/attachment.html>


More information about the llvm-bugs mailing list