]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: guard against non-single use compares in emit_cmp_and_jump_insns
authorTamar Christina <tamar.christina@arm.com>
Wed, 26 Nov 2025 22:00:07 +0000 (22:00 +0000)
committerTamar Christina <tamar.christina@arm.com>
Wed, 26 Nov 2025 22:00:07 +0000 (22:00 +0000)
When I wrote this optimization my patch stack included a change in
tree-out-of-ssa that would duplicate the compares such that the
use is always single use and get_gimple_for_ssa_name would always
succeed.

However I have dropped that for GCC 16 since I didn't expect the
vectorizer to be able to produce duplicate uses of the same
compare results.

But I neglected that you can get it by other means.  So this simply
checks that get_gimple_for_ssa_name succeeds for the LEN cases.
The non-LEN cases already check it earlier on.

To still get the optimization in this case the tree-out-of-ssa
change is needed, which is staged for next stage-1.

gcc/ChangeLog:

* optabs.cc (emit_cmp_and_jump_insns): Check for non-single use.

gcc/optabs.cc

index 9882aac0ba9a377fcedfab2beb5871159e39bd02..0f1495545a496e9045f1a9d35b3b1385a80bc558 100644 (file)
@@ -4895,7 +4895,8 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size,
            }
 
          enum insn_code icode;
-         if (is_gimple_assign (def_stmt)
+         if (def_stmt
+             && is_gimple_assign (def_stmt)
              && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt))
                   == tcc_comparison)
            {