[llvm-bugs] [Bug 42459] New: [InstCombine] ((~x) + y) + 1 -> y - x fold

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 1 03:38:35 PDT 2019


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

            Bug ID: 42459
           Summary: [InstCombine] ((~x) + y) + 1 -> y - x  fold
           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

While this fold is nominally supported, it only happens due to some other
folds,
so it is missed if there are extra uses:
https://godbolt.org/z/ujsxHs
https://rise4fun.com/Alive/EPO0

declare void @use32(i32)

define i32 @t2(i32 %x, i32 %y) {
  %o0 = xor i32 %x, -1
  %o1 = add i32 %o0, %y
  call void @use32(i32 %o1)
  %o2 = add i32 %o1, 1
  ret i32 %o2
}

Name: ((~x) + y) + 1 -> y - x
%o0 = xor i32 %x, -1
%o1 = add i32 %o0, %y
%r = add i32 %o1, 1
  =>
%r = sub i32 %y, %x

-- 
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/20190701/838ea97e/attachment-0001.html>


More information about the llvm-bugs mailing list