http://llvm.org/bugs/show_bug.cgi?id=12706

             Bug #: 12706
           Summary: licm incorrectly hoists divide out of infinite loop,
                    resulting in floating point exception
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


Created attachment 8477
  --> http://llvm.org/bugs/attachment.cgi?id=8477
bug.ll

Compiling the following at -O1 or above in clang results in the division (a /
b) being hoisted outside the loop and a floating point exception.

#include <stdio.h>

__attribute__((noinline)) int f(int a, int b)
{
  while (1) {
    if (b) {
      printf("%d\n", (a / b));
    }
  }
}

int main()
{
  f(1, 0);
  return 0;
}

I've attached the .ll file just before licm pass is run. The issue can be
recreated using opt -licm bug.ll -S and noticing that the sdiv instruction has
been hoisted before the loop.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to