+2017-05-10 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-03-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80122
+ * tree-inline.c (copy_bb): Do not expans va-arg packs or
+ va_arg_pack_len when the inlined call stmt requires pack
+ expansion itself.
+ * tree-inline.h (struct copy_body_data): Make call_stmt a gcall *.
+
+ 2017-03-28 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/80222
+ * gimple-fold.c (gimple_fold_indirect_ref): Do not touch
+ TYPE_REF_CAN_ALIAS_ALL references.
+ * fold-const.c (fold_indirect_ref_1): Likewise.
+
+ 2017-04-06 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80334
+ * tree-ssa-loop-ivopts.c (rewrite_use_address): Properly
+ preserve alignment of accesses.
+
+ 2017-04-27 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/80539
+ * tree-chrec.c (chrec_fold_plus_poly_poly): Deal with not
+ being in loop-closed SSA form conservatively.
+ (chrec_fold_multiply_poly_poly): Likewise.
+
2016-05-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
STRIP_NOPS (sub);
subtype = TREE_TYPE (sub);
- if (!POINTER_TYPE_P (subtype))
+ if (!POINTER_TYPE_P (subtype)
+ || TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (op0)))
return NULL_TREE;
if (TREE_CODE (sub) == ADDR_EXPR)
return false;
}
-/* Given a pointer value OP0, return a simplified version of an
- indirection through OP0, or NULL_TREE if no simplification is
+/* Given a pointer value T, return a simplified version of an
+ indirection through T, or NULL_TREE if no simplification is
possible. Note that the resulting type may be different from
the type pointed to in the sense that it is still compatible
from the langhooks point of view. */
STRIP_NOPS (sub);
subtype = TREE_TYPE (sub);
- if (!POINTER_TYPE_P (subtype))
+ if (!POINTER_TYPE_P (subtype)
+ || TYPE_REF_CAN_ALIAS_ALL (ptype))
return NULL_TREE;
if (TREE_CODE (sub) == ADDR_EXPR)
+2017-05-10 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-03-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80122
+ * gcc.dg/torture/pr80122.c: New testcase.
+
+ 2017-03-28 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/80222
+ * g++.dg/pr80222.C: New testcase.
+
+ 2017-04-06 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/80334
+ * g++.dg/torture/pr80334.C: New testcase.
+
+ 2017-04-27 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/80539
+ * gcc.dg/torture/pr80539.c: New testcase.
+
2016-05-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-optimized" } */
+
+struct C { int i; }__attribute__((may_alias)) ;
+
+C a, b;
+
+int main()
+{
+ a = static_cast <C&> (b);
+}
+
+// { dg-final { scan-tree-dump "{ref-all}\\\)&b\];" "optimized" } } */
--- /dev/null
+// { dg-do run }
+// { dg-additional-options "-std=c++11" }
+
+struct A { alignas(16) char c; };
+struct B { A unpacked; char d; } __attribute__((packed));
+
+char x;
+
+int
+main()
+{
+ alignas(__BIGGEST_ALIGNMENT__) B b[3];
+ for (int i = 0; i < 3; i++) b[i].unpacked.c = 'a' + i;
+ for (int i = 0; i < 3; i++)
+ {
+ auto a = new A(b[i].unpacked);
+ x = a->c;
+ }
+}
--- /dev/null
+/* { dg-do run } */
+
+#define __GNU_ALWAYS_INLINE inline __attribute__(( __always_inline__))
+
+#define DEVT_ALL 0
+
+#define CMD_ABI_DEVICES 100
+
+static __GNU_ALWAYS_INLINE int
+send_msg_to_gm_w_dev_t(int msg_type, unsigned int dev_msg_type,
+ int devt, ...)
+{
+ char s[256];
+ int nArgs = __builtin_va_arg_pack_len();
+ if (nArgs != 2)
+ __builtin_abort ();
+ __builtin_sprintf (s, "%d", __builtin_va_arg_pack ());
+ if (__builtin_strcmp (s, "99") != 0)
+ __builtin_abort ();
+ /* do something with nArgs and ... */
+ return 0;
+}
+
+static __GNU_ALWAYS_INLINE int
+send_msg_to_gm(int msg_type, unsigned int dev_msg_type,
+ ...)
+{
+ int nArgs = __builtin_va_arg_pack_len();
+ if (nArgs != 2)
+ __builtin_abort ();
+ return send_msg_to_gm_w_dev_t(msg_type, dev_msg_type,
+ DEVT_ALL, __builtin_va_arg_pack());
+}
+
+static __GNU_ALWAYS_INLINE int
+send_enable(unsigned int dev_msg_type, ...)
+{
+ int nArgs = __builtin_va_arg_pack_len();
+ if (nArgs != 2)
+ __builtin_abort ();
+ return send_msg_to_gm(CMD_ABI_DEVICES, dev_msg_type, __builtin_va_arg_pack());
+}
+
+int
+main(void)
+{
+ int mode = 99;
+
+ send_enable(1, mode, sizeof(mode));
+
+ return 0;
+}
--- /dev/null
+/* { dg-do compile } */
+
+signed char a, b;
+void fn1()
+{
+ signed char c, e;
+ short d;
+ if (0) {
+ for (; d;) {
+l1:
+ for (c = 7; a; c++)
+ ;
+ e = 6;
+ for (; b; e++)
+ ;
+ }
+ c -= e;
+ }
+ if (d == 7)
+ goto l1;
+ a = c;
+}
/* This function should never be called for chrecs of loops that
do not belong to the same loop nest. */
- gcc_assert (loop0 == loop1);
+ if (loop0 != loop1)
+ {
+ /* It still can happen if we are not in loop-closed SSA form. */
+ gcc_assert (! loops_state_satisfies_p (LOOP_CLOSED_SSA));
+ return chrec_dont_know;
+ }
if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
{
chrec_fold_multiply (type, CHREC_LEFT (poly0), poly1),
CHREC_RIGHT (poly0));
- gcc_assert (loop0 == loop1);
+ if (loop0 != loop1)
+ {
+ /* It still can happen if we are not in loop-closed SSA form. */
+ gcc_assert (! loops_state_satisfies_p (LOOP_CLOSED_SSA));
+ return chrec_dont_know;
+ }
/* poly0 and poly1 are two polynomials in the same variable,
{a, +, b}_x * {c, +, d}_x -> {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x. */
call_stmt = dyn_cast <gcall *> (stmt);
if (call_stmt
&& gimple_call_va_arg_pack_p (call_stmt)
- && id->call_stmt)
+ && id->call_stmt
+ && ! gimple_call_va_arg_pack_p (id->call_stmt))
{
/* __builtin_va_arg_pack () should be replaced by
all arguments corresponding to ... in the caller. */
&& id->call_stmt
&& (decl = gimple_call_fndecl (stmt))
&& DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_ARG_PACK_LEN)
+ && DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_ARG_PACK_LEN
+ && ! gimple_call_va_arg_pack_p (id->call_stmt))
{
/* __builtin_va_arg_pack_len () should be replaced by
the number of anonymous arguments. */
id->src_fn = fn;
id->src_node = cg_edge->callee;
id->src_cfun = DECL_STRUCT_FUNCTION (fn);
- id->call_stmt = stmt;
+ id->call_stmt = call_stmt;
gcc_assert (!id->src_cfun->after_inlining);
/* GIMPLE_CALL if va arg parameter packs should be expanded or NULL
is not. */
- gimple call_stmt;
+ gcall *call_stmt;
/* Exception landing pad the inlined call lies in. */
int eh_lp_nr;
base_hint = var_at_stmt (data->current_loop, cand, use->stmt);
iv = var_at_stmt (data->current_loop, cand, use->stmt);
- ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff,
+ tree type = TREE_TYPE (*use->op_p);
+ unsigned int align = get_object_alignment (*use->op_p);
+ if (align != TYPE_ALIGN (type))
+ type = build_aligned_type (type, align);
+ ref = create_mem_ref (&bsi, type, &aff,
reference_alias_ptr_type (*use->op_p),
iv, base_hint, data->speed);
copy_ref_info (ref, *use->op_p);