shufps moves two of the four packed single-precision floating-point values
from *destination* operand (first operand) into the low quadword of the
destination operand. Match source operand to the destination.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline.
The testcase is relevant only for MMX_WITH_SSE, the fix will be
committed to release branches without testcase.
2020-02-20 Uroš Bizjak <[email protected]>
PR target/93828
* config/i386/mmx.md (*vec_extractv2sf_1): Match source operand
to destination operand for shufps alternative.
(*vec_extractv2si_1): Ditto.
testsuite/ChangeLog:
2020-02-20 Uroš Bizjak <[email protected]>
PR target/93828
* g++.target/i386/pr93828.C: New test.
Uros.
diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index f695831b5b9..e1c8b0af4c7 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -645,14 +645,14 @@
(define_insn "*vec_extractv2sf_1"
[(set (match_operand:SF 0 "nonimmediate_operand" "=y,x,x,y,x,f,r")
(vec_select:SF
- (match_operand:V2SF 1 "nonimmediate_operand" " 0,x,x,o,o,o,o")
+ (match_operand:V2SF 1 "nonimmediate_operand" " 0,x,0,o,o,o,o")
(parallel [(const_int 1)])))]
"(TARGET_MMX || TARGET_MMX_WITH_SSE)
&& !(MEM_P (operands[0]) && MEM_P (operands[1]))"
"@
punpckhdq\t%0, %0
%vmovshdup\t{%1, %0|%0, %1}
- shufps\t{$0xe5, %1, %0|%0, %1, 0xe5}
+ shufps\t{$0xe5, %0, %0|%0, %0, 0xe5}
#
#
#
@@ -1794,7 +1794,7 @@
(define_insn "*vec_extractv2si_1"
[(set (match_operand:SI 0 "nonimmediate_operand" "=y,rm,x,x,y,x,r")
(vec_select:SI
- (match_operand:V2SI 1 "nonimmediate_operand" " 0,x ,x,x,o,o,o")
+ (match_operand:V2SI 1 "nonimmediate_operand" " 0,x ,x,0,o,o,o")
(parallel [(const_int 1)])))]
"(TARGET_MMX || TARGET_MMX_WITH_SSE)
&& !(MEM_P (operands[0]) && MEM_P (operands[1]))"
@@ -1802,7 +1802,7 @@
punpckhdq\t%0, %0
%vpextrd\t{$1, %1, %0|%0, %1, 1}
%vpshufd\t{$0xe5, %1, %0|%0, %1, 0xe5}
- shufps\t{$0xe5, %1, %0|%0, %1, 0xe5}
+ shufps\t{$0xe5, %0, %0|%0, %0, 0xe5}
#
#
#"
diff --git a/gcc/testsuite/g++.target/i386/pr93828.C
b/gcc/testsuite/g++.target/i386/pr93828.C
new file mode 100644
index 00000000000..e0c19751599
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr93828.C
@@ -0,0 +1,17 @@
+// { dg-do run }
+// { dg-require-effective-target c++11 }
+// { dg-options "-O2 -march=k8" }
+
+using float2[[gnu::vector_size (8)]] = float;
+using int2[[gnu::vector_size (8)]] = int;
+float2 y = { 2, 2 };
+
+int
+main ()
+{
+ const auto k = y == float2 { 2, 2 };
+ if (k[1] == 0)
+ __builtin_abort ();
+ const auto a = k & int2 { 2, 2 };
+ return a[0] - 2;
+}