+2020-03-05 Richard Biener <rguenther@suse.de>
+ Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/93582
+ * tree-ssa-sccvn.c (vn_reference_lookup_3): Treat POINTER_PLUS_EXPR
+ last operand as signed when looking for memset offset. Formatting
+ fix.
+
2020-03-04 Andrew Pinski <apinski@marvell.com>
PR bootstrap/93962
+2020-03-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/93582
+ * gcc.dg/tree-ssa/pr93582-11.c: New test.
+
2020-03-04 Martin Sebor <msebor@redhat.com>
PR c++/90938
--- /dev/null
+/* PR tree-optimization/93582 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+/* { dg-final { scan-tree-dump "return 9223372036854775806;" "fre1" } } */
+
+union U { struct A { unsigned long long a : 1, b : 62, c : 1; } a; unsigned long long i; };
+
+unsigned long long
+foo (char *p)
+{
+ __builtin_memset (p - 0xfffffffffffffffULL, 0, 0xffffffffffffffeULL);
+ __builtin_memset (p + 1, 0, 0xffffffffffffffeULL);
+ union U *q = (union U *) (void *) (p - 4);
+ q->a.b = -1;
+ return q->i;
+}
{
poly_int64 soff;
if (TREE_CODE (base) != MEM_REF
- || !(mem_ref_offset (base) << LOG2_BITS_PER_UNIT).to_shwi (&soff))
+ || !(mem_ref_offset (base)
+ << LOG2_BITS_PER_UNIT).to_shwi (&soff))
return (void *)-1;
offset += soff;
offset2 = 0;
if (is_gimple_assign (def)
&& gimple_assign_rhs_code (def) == POINTER_PLUS_EXPR
&& gimple_assign_rhs1 (def) == TREE_OPERAND (base, 0)
- && poly_int_tree_p (gimple_assign_rhs2 (def))
- && (wi::to_poly_offset (gimple_assign_rhs2 (def))
- << LOG2_BITS_PER_UNIT).to_shwi (&offset2))
+ && poly_int_tree_p (gimple_assign_rhs2 (def)))
{
+ tree rhs2 = gimple_assign_rhs2 (def);
+ if (!(poly_offset_int::from (wi::to_poly_wide (rhs2),
+ SIGNED)
+ << LOG2_BITS_PER_UNIT).to_shwi (&offset2))
+ return (void *)-1;
ref2 = gimple_assign_rhs1 (def);
if (TREE_CODE (ref2) == SSA_NAME)
ref2 = SSA_VAL (ref2);