[llvm-bugs] [Bug 31510] New: LLVM is unable to fold a call to pow() with complex arguments
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 2 03:26:22 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31510
Bug ID: 31510
Summary: LLVM is unable to fold a call to pow() with complex
arguments
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: davide at freebsd.org
CC: llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
simon.f.whittaker at gmail.com,
spatel+llvm at rotateright.com
Classification: Unclassified
Testcase:
#include <complex>
std::complex<double> foo()
{
using namespace std::complex_literals;
std::complex<double> z2 = std::pow(1i, 2);
return z2;
}
with (-O3 -std=c++14)
Clang 3.9 output:
.LCPI0_0:
.quad 4607182418800017408 # double 1
foo(): # @foo()
pushq %rbx
subq $16, %rsp
movl $2, %ebx
movsd .LCPI0_0(%rip), %xmm0 # xmm0 = mem[0],zero
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm5
xorpd %xmm4, %xmm4
jmp .LBB0_1
.LBB0_9: # in Loop: Header=BB0_1 Depth=1
movapd %xmm7, %xmm0
movapd %xmm6, %xmm1
movapd %xmm4, %xmm2
movapd %xmm5, %xmm3
movsd %xmm4, 8(%rsp) # 8-byte Spill
movsd %xmm5, (%rsp) # 8-byte Spill
callq __muldc3
movsd (%rsp), %xmm5 # 8-byte Reload
movsd 8(%rsp), %xmm4 # 8-byte Reload
.LBB0_1: # =>This Loop Header: Depth=1
movapd %xmm0, %xmm7
movapd %xmm1, %xmm6
jmp .LBB0_2
.LBB0_5: # in Loop: Header=BB0_2 Depth=2
movapd %xmm0, %xmm2
movapd %xmm1, %xmm3
movsd %xmm6, 8(%rsp) # 8-byte Spill
movsd %xmm7, (%rsp) # 8-byte Spill
callq __muldc3
movsd (%rsp), %xmm7 # 8-byte Reload
movsd 8(%rsp), %xmm6 # 8-byte Reload
movapd %xmm0, %xmm4
movapd %xmm1, %xmm5
jmp .LBB0_6
.LBB0_2: # Parent Loop BB0_1 Depth=1
movapd %xmm4, %xmm0
movapd %xmm5, %xmm1
shrl %ebx
je .LBB0_10
movapd %xmm0, %xmm4
mulsd %xmm4, %xmm4
movapd %xmm1, %xmm2
mulsd %xmm2, %xmm2
movapd %xmm1, %xmm5
mulsd %xmm0, %xmm5
subsd %xmm2, %xmm4
addsd %xmm5, %xmm5
ucomisd %xmm4, %xmm4
jnp .LBB0_6
ucomisd %xmm5, %xmm5
jp .LBB0_5
.LBB0_6: # in Loop: Header=BB0_2 Depth=2
testb $1, %bl
je .LBB0_2
movapd %xmm7, %xmm0
mulsd %xmm4, %xmm0
movapd %xmm6, %xmm2
mulsd %xmm5, %xmm2
movapd %xmm7, %xmm3
mulsd %xmm5, %xmm3
movapd %xmm6, %xmm1
mulsd %xmm4, %xmm1
subsd %xmm2, %xmm0
addsd %xmm3, %xmm1
ucomisd %xmm0, %xmm0
jnp .LBB0_1
ucomisd %xmm1, %xmm1
jnp .LBB0_1
jmp .LBB0_9
.LBB0_10:
movapd %xmm7, %xmm0
movapd %xmm6, %xmm1
addq $16, %rsp
popq %rbx
retq
gcc7 output:
foo():
subq $8, %rsp
pxor %xmm2, %xmm2
movsd .LC0(%rip), %xmm3
movapd %xmm2, %xmm0
movapd %xmm3, %xmm1
call __muldc3
pxor %xmm3, %xmm3
movsd .LC0(%rip), %xmm2
call __muldc3
addq $8, %rsp
ret
.LC0:
.long 0
.long 1072693248
Compiler explorer link if you want to play at home:
https://godbolt.org/g/GGfaei
I think this is not limited only to pow() but it's a place to start (if anybody
is interested)
--
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/20170102/2a7edf9e/attachment-0001.html>
More information about the llvm-bugs
mailing list