52 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mcpu=penryn | FileCheck %s --check-prefix=SSE3; RUN: llc < %s -mcpu=sandybridge | FileCheck %s --check-prefix=AVX4; RUN: llc < %s -mcpu=haswell | FileCheck %s --check-prefix=AVX25; This checks that lowering for creation of constant vectors is sane and6; doesn't use redundant shuffles. (fixes PR22276)7target triple = "x86_64-unknown-unknown"8 9define <4 x i32> @zero_vector() {10; SSE-LABEL: zero_vector:11; SSE: # %bb.0:12; SSE-NEXT: xorps %xmm0, %xmm013; SSE-NEXT: retq14;15; AVX-LABEL: zero_vector:16; AVX: # %bb.0:17; AVX-NEXT: vxorps %xmm0, %xmm0, %xmm018; AVX-NEXT: retq19;20; AVX2-LABEL: zero_vector:21; AVX2: # %bb.0:22; AVX2-NEXT: vxorps %xmm0, %xmm0, %xmm023; AVX2-NEXT: retq24 %zero = insertelement <4 x i32> undef, i32 0, i32 025 %splat = shufflevector <4 x i32> %zero, <4 x i32> undef, <4 x i32> zeroinitializer26 ret <4 x i32> %splat27}28 29; Note that for the "const_vector" versions, lowering that uses a shuffle30; instead of a load would be legitimate, if it's a single broadcast shuffle.31; (as opposed to the previous mess)32; However, this is not the current preferred lowering.33define <4 x i32> @const_vector() {34; SSE-LABEL: const_vector:35; SSE: # %bb.0:36; SSE-NEXT: movaps {{.*#+}} xmm0 = [42,42,42,42]37; SSE-NEXT: retq38;39; AVX-LABEL: const_vector:40; AVX: # %bb.0:41; AVX-NEXT: vbroadcastss {{.*#+}} xmm0 = [42,42,42,42]42; AVX-NEXT: retq43;44; AVX2-LABEL: const_vector:45; AVX2: # %bb.0:46; AVX2-NEXT: vbroadcastss {{.*#+}} xmm0 = [42,42,42,42]47; AVX2-NEXT: retq48 %const = insertelement <4 x i32> undef, i32 42, i32 049 %splat = shufflevector <4 x i32> %const, <4 x i32> undef, <4 x i32> zeroinitializer50 ret <4 x i32> %splat51}52