From ceda727dafba6e05b510b5f8f4ccacfb507dc023 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Fri, 30 Aug 2024 10:36:24 -0700 Subject: phiopt: Ignore some nop statements in heursics [PR116098] The heurstics that was added for PR71016, try to search to see if the conversion was being moved away from its definition. The problem is the heurstics would stop if there was a non GIMPLE_ASSIGN (and already ignores debug statements) and in this case we would have a GIMPLE_LABEL that was not being ignored. So we should need to ignore GIMPLE_NOP, GIMPLE_LABEL and GIMPLE_PREDICT. Note this is now similar to how gimple_empty_block_p behaves. Note this fixes the wrong code that was reported by moving the VCE (conversion) out before the phiopt/match could convert it into an bit_ior and move the VCE out with the VCE being conditionally valid. Bootstrapped and tested on x86_64-linux-gnu. Also built and tested for aarch64-linux-gnu. PR tree-optimization/116098 gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_operation): Ignore nops, labels and predicts for heuristic for conversion with a constant. gcc/testsuite/ChangeLog: * c-c++-common/torture/pr116098-1.c: New test. * gcc.target/aarch64/csel-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/tree-ssa-phiopt.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-phiopt.cc') diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 9a009e1..271a5d5 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -324,8 +324,13 @@ factor_out_conditional_operation (edge e0, edge e1, gphi *phi, gsi_prev_nondebug (&gsi); if (!gsi_end_p (gsi)) { - if (gassign *assign - = dyn_cast (gsi_stmt (gsi))) + gimple *stmt = gsi_stmt (gsi); + /* Ignore nops, predicates and labels. */ + if (gimple_code (stmt) == GIMPLE_NOP + || gimple_code (stmt) == GIMPLE_PREDICT + || gimple_code (stmt) == GIMPLE_LABEL) + ; + else if (gassign *assign = dyn_cast (stmt)) { tree lhs = gimple_assign_lhs (assign); enum tree_code ass_code -- cgit v1.1