Skip to content

Commit 393458f

Browse files
committed
[x86] add negative tests for FP scalarization; NFC
These go with the proposal in D60150. llvm-svn: 357592
1 parent 0484809 commit 393458f

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

llvm/test/CodeGen/X86/scalarize-fp.ll

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,88 @@ define <8 x float> @fdiv_splat_splat_v8f32(<8 x float> %vx, <8 x float> %vy) {
466466
ret <8 x float> %r
467467
}
468468

469+
; Negative test - splat of non-zero indexes (still sink the splat).
470+
471+
define <2 x double> @fadd_splat_splat_nonzero_v2f64(<2 x double> %vx, <2 x double> %vy) {
472+
; SSE-LABEL: fadd_splat_splat_nonzero_v2f64:
473+
; SSE: # %bb.0:
474+
; SSE-NEXT: addpd %xmm1, %xmm0
475+
; SSE-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1,1]
476+
; SSE-NEXT: retq
477+
;
478+
; AVX-LABEL: fadd_splat_splat_nonzero_v2f64:
479+
; AVX: # %bb.0:
480+
; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
481+
; AVX-NEXT: vpermilpd {{.*#+}} xmm0 = xmm0[1,1]
482+
; AVX-NEXT: retq
483+
%splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 1, i32 1>
484+
%splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 1, i32 1>
485+
%r = fadd <2 x double> %splatx, %splaty
486+
ret <2 x double> %r
487+
}
488+
489+
; Negative test - splat of non-zero index and mismatched indexes.
490+
491+
define <2 x double> @fadd_splat_splat_mismatch_v2f64(<2 x double> %vx, <2 x double> %vy) {
492+
; SSE-LABEL: fadd_splat_splat_mismatch_v2f64:
493+
; SSE: # %bb.0:
494+
; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
495+
; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1,1]
496+
; SSE-NEXT: addpd %xmm1, %xmm0
497+
; SSE-NEXT: retq
498+
;
499+
; AVX-LABEL: fadd_splat_splat_mismatch_v2f64:
500+
; AVX: # %bb.0:
501+
; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
502+
; AVX-NEXT: vpermilpd {{.*#+}} xmm1 = xmm1[1,1]
503+
; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
504+
; AVX-NEXT: retq
505+
%splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 0, i32 0>
506+
%splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 1, i32 1>
507+
%r = fadd <2 x double> %splatx, %splaty
508+
ret <2 x double> %r
509+
}
510+
511+
; Negative test - non-splat.
512+
513+
define <2 x double> @fadd_splat_nonsplat_v2f64(<2 x double> %vx, <2 x double> %vy) {
514+
; SSE-LABEL: fadd_splat_nonsplat_v2f64:
515+
; SSE: # %bb.0:
516+
; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
517+
; SSE-NEXT: addpd %xmm1, %xmm0
518+
; SSE-NEXT: retq
519+
;
520+
; AVX-LABEL: fadd_splat_nonsplat_v2f64:
521+
; AVX: # %bb.0:
522+
; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
523+
; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
524+
; AVX-NEXT: retq
525+
%splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 0, i32 0>
526+
%splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 0, i32 1>
527+
%r = fadd <2 x double> %splatx, %splaty
528+
ret <2 x double> %r
529+
}
530+
531+
; Negative test - non-FP.
532+
533+
define <2 x i64> @add_splat_splat_v2i64(<2 x i64> %vx, <2 x i64> %vy) {
534+
; SSE-LABEL: add_splat_splat_v2i64:
535+
; SSE: # %bb.0:
536+
; SSE-NEXT: paddq %xmm1, %xmm0
537+
; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
538+
; SSE-NEXT: retq
539+
;
540+
; AVX-LABEL: add_splat_splat_v2i64:
541+
; AVX: # %bb.0:
542+
; AVX-NEXT: vpaddq %xmm1, %xmm0, %xmm0
543+
; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
544+
; AVX-NEXT: retq
545+
%splatx = shufflevector <2 x i64> %vx, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
546+
%splaty = shufflevector <2 x i64> %vy, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
547+
%r = add <2 x i64> %splatx, %splaty
548+
ret <2 x i64> %r
549+
}
550+
469551
define <2 x double> @fadd_splat_const_op1_v2f64(<2 x double> %vx) {
470552
; SSE-LABEL: fadd_splat_const_op1_v2f64:
471553
; SSE: # %bb.0:

0 commit comments

Comments
 (0)