[llvm-bugs] [Bug 45647] New: Missed peephole: xor-inc-add to xor-sub

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 23 11:03:20 PDT 2020


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

            Bug ID: 45647
           Summary: Missed peephole: xor-inc-add to xor-sub
           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

define i8 @square(i8 %x, i8 %y) {
    %t0 = xor i8 %x, -43
    %t1 = add i8 %t0, 1
    %r = add i8 %t1, %y
    ret i8 %r
}

https://godbolt.org/z/EpjvTY

----------------------------------------
Name: zz
  %t0 = xor i8 %x, -43
  %t1 = add i8 %t0, 1
  %r = add i8 %t1, %y
  ret i8 %r
=>
  %n0 = xor i8 %x, 42
  %r = sub i8 %y, %n0
  ret i8 %r
  %t0 = xor i8 %x, -43
  %t1 = add i8 %t0, 1

Done: 1
Transformation seems to be correct!

-- 
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/20200423/14da8fae/attachment.html>


More information about the llvm-bugs mailing list