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: unassignedb...@nondot.org
          Reporter: lebedev...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to