From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 1FCA83864C65; Wed, 16 Mar 2022 13:00:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FCA83864C65 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7670] tree-optimization/102008 - restore if-conversion of adjacent loads X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 5809bb4f78c9aae0f3be3c8d942b6af75ba23a74 X-Git-Newrev: f6fb661ea8ac7e17c6924719de6219f002c4efef Message-Id: <20220316130052.1FCA83864C65@sourceware.org> Date: Wed, 16 Mar 2022 13:00:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Mar 2022 13:00:52 -0000 https://gcc.gnu.org/g:f6fb661ea8ac7e17c6924719de6219f002c4efef commit r12-7670-gf6fb661ea8ac7e17c6924719de6219f002c4efef Author: Richard Biener Date: Wed Mar 16 13:39:31 2022 +0100 tree-optimization/102008 - restore if-conversion of adjacent loads The following re-orders the newly added code sinking pass before the last phiopt pass which performs hoisting of adjacent loads with the intent to enable if-conversion on those. I've added the aarch64 specific testcase from the PR. 2022-03-16 Richard Biener PR tree-optimization/102008 * passes.def: Move the added code sinking pass before the preceeding phiopt pass. * gcc.target/aarch64/pr102008.c: New testcase. Diff: --- gcc/passes.def | 2 +- gcc/testsuite/gcc.target/aarch64/pr102008.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/passes.def b/gcc/passes.def index f7718181038..c8903b4ec16 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -349,10 +349,10 @@ along with GCC; see the file COPYING3. If not see /* After late CD DCE we rewrite no longer addressed locals into SSA form if possible. */ NEXT_PASS (pass_forwprop); + NEXT_PASS (pass_sink_code); NEXT_PASS (pass_phiopt, false /* early_p */); NEXT_PASS (pass_fold_builtins); NEXT_PASS (pass_optimize_widening_mul); - NEXT_PASS (pass_sink_code); NEXT_PASS (pass_store_merging); NEXT_PASS (pass_tail_calls); /* If DCE is not run before checking for uninitialized uses, diff --git a/gcc/testsuite/gcc.target/aarch64/pr102008.c b/gcc/testsuite/gcc.target/aarch64/pr102008.c new file mode 100644 index 00000000000..d54436c0ffd --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr102008.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct Foo { int a; int b; }; + +int test(int side, const struct Foo *foo) { + if (side == 1) return foo->a; + return foo->b; +} + +/* We want to if-convert the load, not the address. */ +/* { dg-final { scan-assembler-not "add" } } */ +/* { dg-final { scan-assembler-times "csel" 1 } } */