re PR c/84607 (Side effects discarded in address computation inside 'if')

2018-02-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/84607
	* genmatch.c (capture_info::walk_match): Do not mark
	captured expressions without operands as expr_p given
	they act more like predicates and should be subject to
	"lost tail" side-effect preserving.

	* gcc.dg/pr84607.c: New testcase.

From-SVN: r258061
This commit is contained in:
Richard Biener 2018-02-28 13:40:41 +00:00 committed by Richard Biener
parent 35129fd3a7
commit 9348eb677e
4 changed files with 34 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2018-02-28 Richard Biener <rguenther@suse.de>
PR middle-end/84607
* genmatch.c (capture_info::walk_match): Do not mark
captured expressions without operands as expr_p given
they act more like predicates and should be subject to
"lost tail" side-effect preserving.
2018-02-28 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/81611

View file

@ -2104,7 +2104,11 @@ capture_info::walk_match (operand *o, unsigned toplevel_arg,
if (c->what
&& (e = dyn_cast <expr *> (c->what)))
{
info[where].expr_p = true;
/* Zero-operand expression captures like ADDR_EXPR@0 are
similar as predicates -- if they are not mentioned in
the result we have to force them to have no side-effects. */
if (e->ops.length () != 0)
info[where].expr_p = true;
info[where].force_single_use |= e->force_single_use;
}
}

View file

@ -1,3 +1,8 @@
2018-02-28 Richard Biener <rguenther@suse.de>
PR middle-end/84607
* gcc.dg/pr84607.c: New testcase.
2018-02-28 Nathan Sidwell <nathan@acm.org>
PR c++/84602

View file

@ -0,0 +1,16 @@
/* { dg-do run } */
extern void exit(int);
extern void abort(void);
int a[10];
int foo()
{
exit (0);
return 0;
}
int main()
{
if (&a[foo()])
abort ();
return 0;
}