Commit f813d16e by Alexandre Oliva Committed by Alexandre Oliva

[PR67828] don't unswitch on default defs of non-parms

for  gcc/ChangeLog

	PR rtl-optimizatoin/67828
	* tree-ssa-loop-unswitch.c: Include tree-ssa.h.
	(tree_may_unswitch_on): Don't unswitch on expressions
	involving undefined values.

for  gcc/testsuite/ChangeLog

	PR rtl-optimization/67828
	* gcc.dg/torture/pr67828.c: New.

From-SVN: r228650
parent 6be1d686
2015-10-09 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/67828
* tree-ssa-loop-unswitch.c: Include tree-ssa.h.
(tree_may_unswitch_on): Don't unswitch on expressions
involving undefined values.
2015-10-09 Richard Biener <rguenther@suse.de> 2015-10-09 Richard Biener <rguenther@suse.de>
* genmatch.c (print_operand): Fix formatting. * genmatch.c (print_operand): Fix formatting.
2015-10-09 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/67828
* gcc.dg/torture/pr67828.c: New.
2015-10-09 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> 2015-10-09 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/67366 PR target/67366
......
/* Check that we don't misoptimize the final value of d. We used to
apply loop unswitching on if(j), introducing undefined behavior
that the original code wouldn't exercise, and this undefined
behavior would get later passes to misoptimize the loop. */
/* { dg-do run } */
#include <stdio.h>
#include <stdlib.h>
int x;
int __attribute__ ((noinline, noclone))
xprintf (int d) {
if (d)
{
if (x)
printf ("%d", d);
abort ();
}
}
int a, b;
short c;
int
main ()
{
int j, d = 1;
for (; c >= 0; c++)
{
a = d;
d = 0;
if (b)
{
xprintf (0);
if (j)
xprintf (0);
}
}
xprintf (d);
exit (0);
}
...@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "internal-fn.h" #include "internal-fn.h"
#include "gimplify.h" #include "gimplify.h"
#include "tree-cfg.h" #include "tree-cfg.h"
#include "tree-ssa.h"
#include "tree-ssa-loop-niter.h" #include "tree-ssa-loop-niter.h"
#include "tree-ssa-loop.h" #include "tree-ssa-loop.h"
#include "tree-into-ssa.h" #include "tree-into-ssa.h"
...@@ -139,6 +140,10 @@ tree_may_unswitch_on (basic_block bb, struct loop *loop) ...@@ -139,6 +140,10 @@ tree_may_unswitch_on (basic_block bb, struct loop *loop)
/* Condition must be invariant. */ /* Condition must be invariant. */
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
{ {
/* Unswitching on undefined values would introduce undefined
behavior that the original program might never exercise. */
if (ssa_undefined_value_p (use, true))
return NULL_TREE;
def = SSA_NAME_DEF_STMT (use); def = SSA_NAME_DEF_STMT (use);
def_bb = gimple_bb (def); def_bb = gimple_bb (def);
if (def_bb if (def_bb
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment