From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 694B63853804 for ; Mon, 30 May 2022 12:46:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 694B63853804 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8B2DC21B06 for ; Mon, 30 May 2022 12:46:45 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 8565B2C141 for ; Mon, 30 May 2022 12:46:45 +0000 (UTC) Date: Mon, 30 May 2022 12:46:45 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105763 - avoid abnormals with ranger Message-ID: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2022 12:46:47 -0000 In unswitching we use ranger to simplify switch statements so we have to avoid doing anything for abnormals. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2022-05-30 Richard Biener PR tree-optimization/105763 * tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb): Check gimple_range_ssa_p. * gcc.dg/pr105763.c: New testcase. --- gcc/testsuite/gcc.dg/pr105763.c | 21 +++++++++++++++++++++ gcc/tree-ssa-loop-unswitch.cc | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr105763.c diff --git a/gcc/testsuite/gcc.dg/pr105763.c b/gcc/testsuite/gcc.dg/pr105763.c new file mode 100644 index 00000000000..4c76b17e73d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105763.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int rl2_decode_png_bit_depth; +int *rl2_decode_png_p_data; +void png_destroy_read_struct (); +int __attribute__((returns_twice)) _setjmp (); +void rl2_decode_png_row_pointers() +{ + unsigned sample_type = 0; + _setjmp(); + switch (rl2_decode_png_bit_depth) + case 6: + sample_type = 7; + png_destroy_read_struct(); + for (;;) + switch (sample_type) + case 3: + case 5: + *rl2_decode_png_p_data; +} diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc index f32f1a78f00..a55905c2c68 100644 --- a/gcc/tree-ssa-loop-unswitch.cc +++ b/gcc/tree-ssa-loop-unswitch.cc @@ -494,8 +494,7 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop, { unsigned nlabels = gimple_switch_num_labels (stmt); tree idx = gimple_switch_index (stmt); - if (TREE_CODE (idx) != SSA_NAME - || nlabels < 1) + if (!gimple_range_ssa_p (idx) || nlabels < 1) return; /* Index must be invariant. */ def = SSA_NAME_DEF_STMT (idx); -- 2.35.3