[llvm-bugs] [Bug 40483] New: [X86] Failure to merge ISD::SUB(x, y) and X86ISD::SUB(x.y)

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 26 13:38:31 PST 2019


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

            Bug ID: 40483
           Summary: [X86] Failure to merge ISD::SUB(x,y) and
                    X86ISD::SUB(x.y)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

We sometimes fail to recognise that ISD::SUB(x,y) and X86ISD::SUB(x,y) can be
represented by the X86ISD::SUB(x,y).

https://godbolt.org/z/-RFU9J

#include <x86intrin.h>

using u64 = unsigned long long;

u64 test_sub1(u64 *p, u64 x) {
  u64 r = *p - x;
  _subborrow_u64(0, *p, x, p);
  return *p - r; // zero
}

u64 test_sub2(u64 *p, u64 x) {
  u64 r = *p - x;
  _subborrow_u64(0, *p, x, p);
  return r - *p; // zero
}

_Z9test_sub1Pyy:
        movq    (%rdi), %rcx
        movq    %rcx, %rax
        subq    %rsi, %rax
        movq    %rax, (%rdi)
        subq    %rcx, %rsi
        addq    %rsi, %rax
        retq
_Z9test_sub2Pyy:
        subq    %rsi, (%rdi)
        xorl    %eax, %eax
        retq

-- 
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/20190126/717d4f3f/attachment.html>


More information about the llvm-bugs mailing list