[llvm-bugs] [Bug 38239] New: Missed simplication of division

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 19 21:50:18 PDT 2018


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

            Bug ID: 38239
           Summary: Missed simplication of division
           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

Hello,

int f1(int x, int y, int z) {
    return (z * x) / (z * y);
}

f1(int, int, int):
  imul edi, edx
  imul esi, edx
  mov eax, edi
  cdq
  idiv esi
  ret

Possibly, this can be transformed to "return x / y" ? z = 0 leads to "division
by zero is undefined".

f2(int, int):
  mov eax, edi
  cdq
  idiv esi
  ret

-- 
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/20180720/e54518b1/attachment.html>


More information about the llvm-bugs mailing list