[llvm-bugs] [Bug 42457] New: [InstCombine] `x - ~(y)` vs `x + y + 1`

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 30 15:21:42 PDT 2019


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


int bad(unsigned x, unsigned y) {
    return x - ~(y);
int good(unsigned x, unsigned y) {
    return x + y + 1;

%o = xor i32 %y, -1
%r = sub i32 %x, %o
%n = add i32 %y, 1
%r = add i32 %x, %n

We currently don't prefer any one to other, should we?
I'd guess we want the variant with 2 adds?

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/9d0dc70b/attachment.html>

More information about the llvm-bugs mailing list