[llvm-bugs] [Bug 34110] New: Compiler not generating hadd/hsub instructions for simple pattern
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 7 18:00:06 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34110
Bug ID: 34110
Summary: Compiler not generating hadd/hsub instructions for
simple pattern
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: douglas_yung at playstation.sony.com
CC: llvm-bugs at lists.llvm.org
After commit r310260, the following code no longer generates horizontal
add/subtract instructions when compiled with optimizations enabled:
__m128 hadd2ps(__m128 a, __m128 b)
{
return (__m128){ a[0] + a[1], a[2] + a[3], b[0] + b[1], b[2] + b[3] };
}
Prior to r310260, the code above when compiled would generate the following x86
assembly:
clang -S -O2 repro.cpp -mavx -o -:
.cfi_startproc
# BB#0: # %entry
vhaddps %xmm1, %xmm0, %xmm0
retq
But starting with r310260, the compiler no longer generates the horizontal add
instruction:
clang -S -O2 repro.cpp -mavx -o -:
.cfi_startproc
# BB#0: # %entry
vpermilps $232, %xmm0, %xmm2 # xmm2 = xmm0[0,2,2,3]
vpermilps $237, %xmm0, %xmm0 # xmm0 = xmm0[1,3,2,3]
vpermilpd $1, %xmm1, %xmm3 # xmm3 = xmm1[1,0]
vaddps %xmm0, %xmm2, %xmm0
vmovshdup %xmm1, %xmm2 # xmm2 = xmm1[1,1,3,3]
vaddss %xmm2, %xmm1, %xmm2
vpermilps $231, %xmm1, %xmm1 # xmm1 = xmm1[3,1,2,3]
vaddss %xmm1, %xmm3, %xmm1
vinsertps $32, %xmm2, %xmm0, %xmm0 # xmm0 =
xmm0[0,1],xmm2[0],xmm0[3]
vinsertps $48, %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0,1,2],xmm1[0]
retq
This suboptimal codegen also applies to the horizontal subtraction case.
--
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/20170808/3eb1e0bd/attachment.html>
More information about the llvm-bugs
mailing list