diff options
author | Richard Biener <rguenther@suse.de> | 2022-10-18 09:38:03 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-10-18 09:39:00 +0200 |
commit | 5ad3cc1ecc3c7c61d5e319f74cb7287fb80944fd (patch) | |
tree | be796c6282ef5d5de6f0c74079f4ce79399f2382 /gcc | |
parent | 35106383c0995682f3bef20f745285f791796473 (diff) | |
download | gcc-5ad3cc1ecc3c7c61d5e319f74cb7287fb80944fd.zip gcc-5ad3cc1ecc3c7c61d5e319f74cb7287fb80944fd.tar.gz gcc-5ad3cc1ecc3c7c61d5e319f74cb7287fb80944fd.tar.bz2 |
tree-optimization/107301 - check if we can duplicate block before doing so
Path isolation failed to do that.
PR tree-optimization/107301
* gimple-ssa-isolate-paths.cc (handle_return_addr_local_phi_arg):
Check whether we can duplicate the block.
(find_implicit_erroneous_behavior): Likewise.
* gcc.dg/torture/pr107301.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-ssa-isolate-paths.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr107301.c | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/gimple-ssa-isolate-paths.cc b/gcc/gimple-ssa-isolate-paths.cc index 87ecd19..e4a4e08 100644 --- a/gcc/gimple-ssa-isolate-paths.cc +++ b/gcc/gimple-ssa-isolate-paths.cc @@ -647,7 +647,8 @@ handle_return_addr_local_phi_arg (basic_block bb, basic_block duplicate, if (!maybe && (flag_isolate_erroneous_paths_dereference || flag_isolate_erroneous_paths_attribute) - && gimple_bb (use_stmt) == bb) + && gimple_bb (use_stmt) == bb + && (duplicate || can_duplicate_block_p (bb))) { duplicate = isolate_path (bb, duplicate, e, use_stmt, lhs, true); @@ -765,7 +766,8 @@ find_implicit_erroneous_behavior (void) ? gimple_location (use_stmt) : phi_arg_loc; - if (stmt_uses_name_in_undefined_way (use_stmt, lhs, loc)) + if (stmt_uses_name_in_undefined_way (use_stmt, lhs, loc) + && (duplicate || can_duplicate_block_p (bb))) { duplicate = isolate_path (bb, duplicate, e, use_stmt, lhs, false); diff --git a/gcc/testsuite/gcc.dg/torture/pr107301.c b/gcc/testsuite/gcc.dg/torture/pr107301.c new file mode 100644 index 0000000..5f0afcc --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr107301.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +__attribute__ ((pure, returns_twice)) int +foo (int x) +{ + int a; + + a = x ? 3 : 0; + x /= a; + a = foo (x); + if (x == a) + __builtin_unreachable (); + + return 0; +} |