re PR tree-optimization/84383 (ICE in maybe_diag_stxncpy_trunc)

PR tree-optimization/84383
	* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Don't look at
	dstoff nor call operand_equal_p if dstbase is NULL.

	* gcc.c-torture/compile/pr84383.c: New test.

From-SVN: r257684
This commit is contained in:
Jakub Jelinek 2018-02-15 12:18:47 +01:00 committed by Jakub Jelinek
parent 3eb1eecf29
commit 44e60df333
4 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2018-02-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/84383
* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Don't look at
dstoff nor call operand_equal_p if dstbase is NULL.
PR tree-optimization/84334
* match.pd ((A +- CST1) +- CST2 -> A + CST3): If A is
also a CONSTANT_CLASS_P, punt.

View File

@ -1,5 +1,8 @@
2018-02-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/84383
* gcc.c-torture/compile/pr84383.c: New test.
PR tree-optimization/84334
* gcc.dg/pr84334.c: New test.

View File

@ -0,0 +1,14 @@
/* PR tree-optimization/84383 */
struct S { char *s; };
void bar (struct S *);
void
foo (int a, char *b)
{
struct S c[4];
bar (c);
__builtin_strncpy (c[a].s, b, 32);
c[a].s[31] = '\0';
bar (c);
}

View File

@ -1878,6 +1878,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
poly_int64 lhsoff;
tree lhsbase = get_addr_base_and_unit_offset (lhs, &lhsoff);
if (lhsbase
&& dstbase
&& known_eq (dstoff, lhsoff)
&& operand_equal_p (dstbase, lhsbase, 0))
return false;