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

Reply via email to