From a92910ae13f63d21d194bada3ae904a305d87bd8 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 31 Jul 2008 14:12:24 +0000 Subject: [PATCH] 2008-07-31 Richard Guenther PR tree-optimization/36978 * tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Do not fold the generated condition. * gcc.dg/torture/pr36978.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138415 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr36978.c | 14 ++++++++++++++ gcc/tree-ssa-loop-unswitch.c | 4 ++-- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr36978.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb7a67b6513..c83a2faa81c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2008-07-31 Richard Guenther + PR tree-optimization/36978 + * tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Do not fold + the generated condition. + +2008-07-31 Richard Guenther + * passes.c (init_optimization_passes): Always call pass_early_warn_uninitialized. * opts.c (decode_options): Do not warn about -Wuninitialized diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ccbd9711809..f6e855abd08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-07-31 Richard Guenther + + PR tree-optimization/36978 + * gcc.dg/torture/pr36978.c: New testcase. + 2008-07-31 Arnaud Charlet * gnat.dg/sync_iface_test.ad[s,b]: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr36978.c b/gcc/testsuite/gcc.dg/torture/pr36978.c new file mode 100644 index 00000000000..cd1af4ebc08 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr36978.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-funswitch-loops" } */ + +unsigned short status; +void foo (const _Bool flag) +{ + if (status == 2 || status == 7) + { + while (status != 2 && (status != 7 || !flag)) + { + } + } +} + diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 8ece4aca4ab..850270f49c0 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -123,8 +123,8 @@ tree_may_unswitch_on (basic_block bb, struct loop *loop) return NULL_TREE; } - cond = fold_build2 (gimple_cond_code (stmt), boolean_type_node, - gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); + cond = build2 (gimple_cond_code (stmt), boolean_type_node, + gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); /* To keep the things simple, we do not directly remove the conditions, but just replace tests with 0/1. Prevent the infinite loop where we -- 2.11.0