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

            Bug ID: 19530
           Summary: LLVM generates incorrect tailcall on x86
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Consider the following LLVM IR:

```
$ cat test.ll
declare double    @llvm.powi.f64(double %Val, i32 %power)
define <3 x double> @julia_foo17589(i64) {
top:
  %1 = trunc i64 %0 to i32
  %2 = call double @llvm.powi.f64(double 1.000000e+00, i32 %1)
  %3 = insertelement <3 x double> undef, double %2, i32 0
  %4 = call double @llvm.powi.f64(double 2.000000e+00, i32 %1)
  %5 = insertelement <3 x double> %3, double %4, i32 1
  %6 = call double @llvm.powi.f64(double 3.000000e+00, i32 %1)
  %7 = insertelement <3 x double> %5, double %6, i32 2
  ret <3 x double> %7
}
define i64 @main(i32) {
  %arg = zext i32 %0 to i64
  %a = call <3 x double> @julia_foo17589(i64 %arg)
  %b = extractelement <3 x double> %a, i32 0
  %c = fcmp ueq double %b, 1.000000e+00
  %d = zext i1 %c to i64
  ret i64 %d
}
```

Calling `llc -O0 -mcpu=core2 test.ll`
gives (exerted below)
```
_julia_foo17589:                        ## @julia_foo17589
    .cfi_startproc
## BB#0:                                ## %top
    movl    %edi, %eax
    movsd    LCPI0_0(%rip), %xmm0
    movl    %eax, %edi
    jmp    ___powidf2              ## TAILCALL
    .cfi_endproc
```
The tailcall there is incorrect and gives the wrong result. This is machine
dependent and works correctly on some machines (without the -mcpu), but not
others.

-- 
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