[llvm] 3a2645e - [X86][SSE] Add HADD combine regression case from rG9bd97d036398

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 10:26:46 PDT 2020


Author: Simon Pilgrim
Date: 2020-08-13T18:24:55+01:00
New Revision: 3a2645e42899fe5a70df4bdb04acceea0e9db155

URL: https://github.com/llvm/llvm-project/commit/3a2645e42899fe5a70df4bdb04acceea0e9db155
DIFF: https://github.com/llvm/llvm-project/commit/3a2645e42899fe5a70df4bdb04acceea0e9db155.diff

LOG: [X86][SSE] Add HADD combine regression case from rG9bd97d036398

rG9bd97d036398 caused a miscompile of this internal test case

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/haddsub-undef.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/haddsub-undef.ll b/llvm/test/CodeGen/X86/haddsub-undef.ll
index a90e8b67a8ca..fb420b4fd806 100644
--- a/llvm/test/CodeGen/X86/haddsub-undef.ll
+++ b/llvm/test/CodeGen/X86/haddsub-undef.ll
@@ -575,6 +575,57 @@ define <4 x float> @add_ps_008(<4 x float> %x) {
   ret <4 x float> %add
 }
 
+define <4 x float> @add_ps_016(<4 x float> %0, <4 x float> %1) {
+; SSE-SLOW-LABEL: add_ps_016:
+; SSE-SLOW:       # %bb.0:
+; SSE-SLOW-NEXT:    movhlps {{.*#+}} xmm0 = xmm0[1,1]
+; SSE-SLOW-NEXT:    movshdup {{.*#+}} xmm2 = xmm1[1,1,3,3]
+; SSE-SLOW-NEXT:    addps %xmm1, %xmm2
+; SSE-SLOW-NEXT:    haddps %xmm0, %xmm1
+; SSE-SLOW-NEXT:    shufps {{.*#+}} xmm2 = xmm2[2,0],xmm1[0,0]
+; SSE-SLOW-NEXT:    shufps {{.*#+}} xmm2 = xmm2[0,2],xmm1[2,3]
+; SSE-SLOW-NEXT:    movaps %xmm2, %xmm0
+; SSE-SLOW-NEXT:    retq
+;
+; SSE-FAST-LABEL: add_ps_016:
+; SSE-FAST:       # %bb.0:
+; SSE-FAST-NEXT:    movhlps {{.*#+}} xmm0 = xmm0[1,1]
+; SSE-FAST-NEXT:    movaps %xmm1, %xmm2
+; SSE-FAST-NEXT:    haddps %xmm0, %xmm2
+; SSE-FAST-NEXT:    haddps %xmm1, %xmm1
+; SSE-FAST-NEXT:    shufps {{.*#+}} xmm1 = xmm1[3,1],xmm2[0,0]
+; SSE-FAST-NEXT:    shufps {{.*#+}} xmm1 = xmm1[0,2],xmm2[2,3]
+; SSE-FAST-NEXT:    movaps %xmm1, %xmm0
+; SSE-FAST-NEXT:    retq
+;
+; AVX-SLOW-LABEL: add_ps_016:
+; AVX-SLOW:       # %bb.0:
+; AVX-SLOW-NEXT:    vpermilpd {{.*#+}} xmm0 = xmm0[1,0]
+; AVX-SLOW-NEXT:    vhaddps %xmm0, %xmm1, %xmm0
+; AVX-SLOW-NEXT:    vmovshdup {{.*#+}} xmm2 = xmm1[1,1,3,3]
+; AVX-SLOW-NEXT:    vaddps %xmm1, %xmm2, %xmm1
+; AVX-SLOW-NEXT:    vshufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[0,0]
+; AVX-SLOW-NEXT:    vshufps {{.*#+}} xmm0 = xmm1[0,2],xmm0[2,3]
+; AVX-SLOW-NEXT:    retq
+;
+; AVX-FAST-LABEL: add_ps_016:
+; AVX-FAST:       # %bb.0:
+; AVX-FAST-NEXT:    vpermilpd {{.*#+}} xmm0 = xmm0[1,0]
+; AVX-FAST-NEXT:    vhaddps %xmm0, %xmm1, %xmm0
+; AVX-FAST-NEXT:    vhaddps %xmm1, %xmm1, %xmm1
+; AVX-FAST-NEXT:    vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[3,3]
+; AVX-FAST-NEXT:    vpermilps {{.*#+}} xmm0 = xmm0[2,0,1,3]
+; AVX-FAST-NEXT:    retq
+  %3 = shufflevector <4 x float> %1, <4 x float> %0, <2 x i32> <i32 0, i32 6>
+  %4 = shufflevector <4 x float> %1, <4 x float> %0, <2 x i32> <i32 1, i32 7>
+  %5 = fadd <2 x float> %3, %4
+  %6 = shufflevector <2 x float> %5, <2 x float> undef, <4 x i32> <i32 undef, i32 0, i32 1, i32 undef>
+  %7 = shufflevector <4 x float> %1, <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+  %8 = fadd <4 x float> %7, %1
+  %9 = shufflevector <4 x float> %6, <4 x float> %8, <4 x i32> <i32 6, i32 1, i32 2, i32 undef>
+  ret <4 x float> %9
+}
+
 define <4 x float> @add_ps_017(<4 x float> %x) {
 ; SSE-SLOW-LABEL: add_ps_017:
 ; SSE-SLOW:       # %bb.0:


        


More information about the llvm-commits mailing list