Use shuffles to implement insert_vector_elt for i32, i64, f32, and f64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44929 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/X86/2007-07-31-VInsertBug.ll b/test/CodeGen/X86/2007-07-31-VInsertBug.ll
deleted file mode 100644
index 1b13b08..0000000
--- a/test/CodeGen/X86/2007-07-31-VInsertBug.ll
+++ /dev/null
@@ -1,16 +0,0 @@
-; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin -mattr=+sse2 | %prcontext {pinsrw \$2} 1 | grep "movl \$1"
-; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin -mattr=+sse2 | not grep movss
-
-@G = global <4 x float> zeroinitializer
-
-define void @test(i32 *%P1, i32* %P2, float *%FP) {
-        %T = load float* %FP
-        store i32 0, i32* %P1
-
-        %U = load <4 x float>* @G
-        store i32 1, i32* %P1
-        %V = insertelement <4 x float> %U, float %T, i32 1
-        store <4 x float> %V, <4 x float>* @G
-
-        ret void
-}
diff --git a/test/CodeGen/X86/vec_insert-2.ll b/test/CodeGen/X86/vec_insert-2.ll
new file mode 100644
index 0000000..8fc97bf
--- /dev/null
+++ b/test/CodeGen/X86/vec_insert-2.ll
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep pinsrw | count 1
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movhpd | count 1
+; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+sse2 | grep unpcklpd | count 1
+
+define <4 x float> @t1(float %s, <4 x float> %tmp) {
+        %tmp1 = insertelement <4 x float> %tmp, float %s, i32 3
+        ret <4 x float> %tmp1
+}
+
+define <4 x i32> @t2(i32 %s, <4 x i32> %tmp) {
+        %tmp1 = insertelement <4 x i32> %tmp, i32 %s, i32 3
+        ret <4 x i32> %tmp1
+}
+
+define <2 x double> @t3(double %s, <2 x double> %tmp) {
+        %tmp1 = insertelement <2 x double> %tmp, double %s, i32 1
+        ret <2 x double> %tmp1
+}
+
+define <8 x i16> @t4(i16 %s, <8 x i16> %tmp) {
+        %tmp1 = insertelement <8 x i16> %tmp, i16 %s, i32 5
+        ret <8 x i16> %tmp1
+}
diff --git a/test/CodeGen/X86/vec_insert-3.ll b/test/CodeGen/X86/vec_insert-3.ll
new file mode 100644
index 0000000..1d374b4
--- /dev/null
+++ b/test/CodeGen/X86/vec_insert-3.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+sse2 | grep punpcklqdq | count 1
+
+define <2 x i64> @t1(i64 %s, <2 x i64> %tmp) {
+        %tmp1 = insertelement <2 x i64> %tmp, i64 %s, i32 1
+        ret <2 x i64> %tmp1
+}
diff --git a/test/CodeGen/X86/vec_insert.ll b/test/CodeGen/X86/vec_insert.ll
index 8ee0484..c8c9f14 100644
--- a/test/CodeGen/X86/vec_insert.ll
+++ b/test/CodeGen/X86/vec_insert.ll
@@ -1,20 +1,19 @@
-; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 -mattr=+sse2 -o %t -f
-; RUN: grep movss  %t | count 1
-; RUN: grep pinsrw %t | count 2
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movss | count 1
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | not grep pinsrw
 
-void %test(<4 x float>* %F, int %I) {
-	%tmp = load <4 x float>* %F
-	%f = cast int %I to float
-	%tmp1 = insertelement <4 x float> %tmp, float %f, uint 0
-	%tmp18 = add <4 x float> %tmp1, %tmp1
+define void @test(<4 x float>* %F, i32 %I) {
+	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=1]
+	%f = sitofp i32 %I to float		; <float> [#uses=1]
+	%tmp1 = insertelement <4 x float> %tmp, float %f, i32 0		; <<4 x float>> [#uses=2]
+	%tmp18 = add <4 x float> %tmp1, %tmp1		; <<4 x float>> [#uses=1]
 	store <4 x float> %tmp18, <4 x float>* %F
 	ret void
 }
 
-void %test2(<4 x float>* %F, int %I, float %g) {
-	%tmp = load <4 x float>* %F
-	%f = cast int %I to float
-	%tmp1 = insertelement <4 x float> %tmp, float %f, uint 2
+define void @test2(<4 x float>* %F, i32 %I, float %g) {
+	%tmp = load <4 x float>* %F		; <<4 x float>> [#uses=1]
+	%f = sitofp i32 %I to float		; <float> [#uses=1]
+	%tmp1 = insertelement <4 x float> %tmp, float %f, i32 2		; <<4 x float>> [#uses=1]
 	store <4 x float> %tmp1, <4 x float>* %F
 	ret void
 }