--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O -fno-math-errno" } */
+
+typedef double __m128d __attribute__((vector_size(16)));
+__m128d vsqrt1 (__m128d const x)
+{
+ double const* __restrict__ const y = (double const*)&x;
+ double const a = __builtin_sqrt(y[0]);
+ double const b = __builtin_sqrt(y[1]);
+ return (__m128d) { a, b };
+}
+
+/* Verify we do not spill x to the stack. */
+/* { dg-final { scan-assembler-not "%rsp" } } */
tp = &TREE_OPERAND (*tp, 0);
if (TREE_CODE (*tp) == MEM_REF
&& TREE_CODE (TREE_OPERAND (*tp, 0)) == ADDR_EXPR
- && integer_zerop (TREE_OPERAND (*tp, 1))
&& (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0))
&& DECL_P (sym)
&& !TREE_ADDRESSABLE (sym)
&& symbol_marked_for_renaming (sym))
{
- if (!useless_type_conversion_p (TREE_TYPE (*tp),
- TREE_TYPE (sym)))
- *tp = build1 (VIEW_CONVERT_EXPR,
- TREE_TYPE (*tp), sym);
- else
- *tp = sym;
+ if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE
+ && useless_type_conversion_p (TREE_TYPE (*tp),
+ TREE_TYPE (TREE_TYPE (sym)))
+ && multiple_of_p (sizetype, TREE_OPERAND (*tp, 1),
+ TYPE_SIZE_UNIT (TREE_TYPE (*tp))))
+ {
+ *tp = build3 (BIT_FIELD_REF, TREE_TYPE (*tp), sym,
+ TYPE_SIZE (TREE_TYPE (*tp)),
+ int_const_binop (MULT_EXPR,
+ bitsize_int (BITS_PER_UNIT),
+ TREE_OPERAND (*tp, 1), 0));
+ }
+ else if (integer_zerop (TREE_OPERAND (*tp, 1)))
+ {
+ if (!useless_type_conversion_p (TREE_TYPE (*tp),
+ TREE_TYPE (sym)))
+ *tp = build1 (VIEW_CONVERT_EXPR,
+ TREE_TYPE (*tp), sym);
+ else
+ *tp = sym;
+ }
}
}
base = TREE_OPERAND (base, 0);
/* But watch out for MEM_REFs we cannot lower to a
- VIEW_CONVERT_EXPR. */
+ VIEW_CONVERT_EXPR or a BIT_FIELD_REF. */
if (TREE_CODE (base) == MEM_REF
&& TREE_CODE (TREE_OPERAND (base, 0)) == ADDR_EXPR)
{
tree decl = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
+ if (TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE
+ && useless_type_conversion_p (TREE_TYPE (base),
+ TREE_TYPE (TREE_TYPE (decl)))
+ && double_int_fits_in_uhwi_p (mem_ref_offset (base))
+ && multiple_of_p (sizetype, TREE_OPERAND (base, 1),
+ TYPE_SIZE_UNIT (TREE_TYPE (base))))
+ return NULL_TREE;
if (DECL_P (decl)
&& (!integer_zerop (TREE_OPERAND (base, 1))
|| (DECL_SIZE (decl)