summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ifcombine.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2015-11-03 00:30:07 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2015-11-03 00:30:07 +0000
commit828ca3d835ac006cbcb2e5b480c6429cc8a75bdd (patch)
tree97886b9d02ac0ccd0177983b325624a1c00e5f03 /gcc/tree-ssa-ifcombine.c
parentdac7e9b81974a69fc437d5115ebb46de11da14de (diff)
[PR68083] don't introduce undefined behavior in ifcombine
The ifcombine pass may move a conditional access to an uninitialized value before the condition that ensures it is always well-defined, thus introducing undefined behavior. Stop it from doing so. for gcc/ChangeLog PR tree-optimization/68083 * tree-ssa-ifcombine.c: Include tree-ssa.h. (bb_no_side_effects_p): Test for undefined uses too. * tree-ssa.c (gimple_uses_undefined_value_p): New. * tree-ssa.h (gimple_uses_undefined_value_p): Declare. for gcc/testsuite/ChangeLog PR tree-optimization/68083 * gcc.dg/torture/pr68083.c: New. From Zhendong Su. From-SVN: r229690
Diffstat (limited to 'gcc/tree-ssa-ifcombine.c')
-rw-r--r--gcc/tree-ssa-ifcombine.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index b812d9a8fc5..c18de7e607e 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-iterator.h"
#include "gimplify-me.h"
#include "tree-cfg.h"
+#include "tree-ssa.h"
#ifndef LOGICAL_OP_NON_SHORT_CIRCUIT
#define LOGICAL_OP_NON_SHORT_CIRCUIT \
@@ -122,6 +123,7 @@ bb_no_side_effects_p (basic_block bb)
continue;
if (gimple_has_side_effects (stmt)
+ || gimple_uses_undefined_value_p (stmt)
|| gimple_could_trap_p (stmt)
|| gimple_vuse (stmt))
return false;