}
gcc_assert (extractindex < nelt);
- emit_move_insn (d->target, insv);
insn_code icode = code_for_aarch64_simd_vec_copy_lane (mode);
expand_operand ops[5];
create_output_operand (&ops[0], d->target, mode);
- create_input_operand (&ops[1], d->target, mode);
+ create_input_operand (&ops[1], insv, mode);
create_integer_operand (&ops[2], 1 << idx);
create_input_operand (&ops[3], extractv, mode);
create_integer_operand (&ops[4], extractindex);
--- /dev/null
+/* { dg-do run } */
+/* PR target/101529 */
+
+typedef unsigned char __attribute__((__vector_size__ (1))) W;
+typedef unsigned char __attribute__((__vector_size__ (8))) V;
+typedef unsigned short __attribute__((__vector_size__ (16))) U;
+
+unsigned short us;
+
+/* aarch64 used to miscompile foo to just return 0. */
+W
+foo (unsigned char uc)
+{
+ V v = __builtin_convertvector ((U){ } >= us, V);
+ return __builtin_shufflevector ((W){ }, v, 4) & uc;
+}
+
+int
+main (void)
+{
+ W x = foo (5);
+ if (x[0] != 5)
+ __builtin_abort();
+ return 0;
+}
+
--- /dev/null
+/* { dg-do run} */
+/* PR target/101529 */
+typedef unsigned char C;
+typedef unsigned char __attribute__((__vector_size__ (8))) V;
+typedef unsigned char __attribute__((__vector_size__ (32))) U;
+
+C c;
+
+/* aarch64 used to miscompile foo to just return a vector of 0s */
+V
+foo (V v)
+{
+ v |= __builtin_shufflevector (c * v, (U) (0 == (U){ }),
+ 0, 1, 8, 32, 8, 20, 36, 36);
+ return v;
+}
+
+int
+main (void)
+{
+ V v = foo ((V) { });
+ for (unsigned i = 0; i < sizeof (v); i++)
+ if (v[i] != (i >= 2 ? 0xff : 0))
+ __builtin_abort ();
+ return 0;
+}