[llvm-bugs] [Bug 44234] New: Missed negation pattern

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 6 01:27:48 PST 2019


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

            Bug ID: 44234
           Summary: Missed negation pattern
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

int f1 (int t, int v, int x)
{
  int a = t - x;
  int b = a * v;
  return 0 - b;
}

int f2 (int t, int v, int x)
{
  int a = v - t;
  int b = a * x;
  return 0 - b;
}


GCC:
f1(int, int, int):
        sub     edx, edi
        mov     eax, edx
        imul    eax, esi
        ret
f2(int, int, int):
        sub     edi, esi
        mov     eax, edi
        imul    eax, edx
        ret

LLVM:
f1(int, int, int):                              
        mov     eax, edi
        sub     eax, edx
        imul    eax, esi
        neg     eax
        ret
f2(int, int, int):                              
        mov     eax, esi
        sub     eax, edi
        imul    eax, edx
        neg     eax
        ret


https://godbolt.org/z/afTGuz

-- 
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/20191206/b87a7f10/attachment-0001.html>


More information about the llvm-bugs mailing list