https://gcc.gnu.org/g:28bac52566bc4a42b1dcfb1dde0a12fe3b75ed36
commit r16-5683-g28bac52566bc4a42b1dcfb1dde0a12fe3b75ed36 Author: Tamar Christina <[email protected]> Date: Fri Nov 28 07:45:51 2025 +0000 middle-end: check that the argument is an SSA_NAME before calling get_gimple_for_ssa_name [PR122890] This checks if the arguments of the boolean operation are an SSA_NAME before we try to lookup their definition. gcc/ChangeLog: PR middle-end/122890 * optabs.cc (emit_cmp_and_jump_insns): Check for SSA Name. gcc/testsuite/ChangeLog: PR middle-end/122890 * g++.target/aarch64/pr122890.C: New test. Diff: --- gcc/optabs.cc | 13 ++++++++----- gcc/testsuite/g++.target/aarch64/pr122890.C | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gcc/optabs.cc b/gcc/optabs.cc index 0f1495545a49..183ad910fcd7 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -4854,13 +4854,15 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, gimple *mask_def = NULL; tree rhs1 = gimple_assign_rhs1 (def_stmt); tree rhs2 = gimple_assign_rhs2 (def_stmt); - if ((mask_def = get_gimple_for_ssa_name (rhs1)) + if (TREE_CODE (rhs1) == SSA_NAME + && (mask_def = get_gimple_for_ssa_name (rhs1)) && is_gimple_assign (mask_def) && TREE_CODE_CLASS (gimple_assign_rhs_code (mask_def))) masked_op = rhs2; - else if ((mask_def = get_gimple_for_ssa_name (rhs2)) - && is_gimple_assign (mask_def) - && TREE_CODE_CLASS (gimple_assign_rhs_code (mask_def))) + else if (TREE_CODE (rhs2) == SSA_NAME + && (mask_def = get_gimple_for_ssa_name (rhs2)) + && is_gimple_assign (mask_def) + && TREE_CODE_CLASS (gimple_assign_rhs_code (mask_def))) masked_op = rhs1; if (masked_op) @@ -4890,7 +4892,8 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, len_bias = gimple_call_arg (call, 4); tree arg0 = gimple_call_arg (call, 0); - def_stmt = get_gimple_for_ssa_name (arg0); + if (TREE_CODE (arg0) == SSA_NAME) + def_stmt = get_gimple_for_ssa_name (arg0); } } diff --git a/gcc/testsuite/g++.target/aarch64/pr122890.C b/gcc/testsuite/g++.target/aarch64/pr122890.C new file mode 100644 index 000000000000..2b7426486d42 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/pr122890.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv8-a -std=c++11 -Ofast" } */ + +#include <vector> + +int foo() +{ + bool xs[] = { true, true, false, true }; + bool s[] = { true, true, false }; + std::vector<bool> x(xs, xs+4); + std::vector<bool> g(s, s+3); + g.push_back(true); + if (g != x) + __builtin_abort(); + return 0; +}
