https://gcc.gnu.org/g:28982c271cbbed3580e4c7c784892694c3b6b2de
commit r15-4351-g28982c271cbbed3580e4c7c784892694c3b6b2de Author: Richard Biener <rguent...@suse.de> Date: Tue Oct 15 10:23:06 2024 +0200 tree-optimization/117138 - fix ICE with vector comparison in COND_EXPR The range folding code of COND_EXPRs missed a check whether the comparison operand type is supported. PR tree-optimization/117138 * gimple-range-fold.cc (fold_using_range::condexpr_adjust): Check if the comparison operand type is supported. * gcc.dg/torture/pr117138.c: New testcase. Diff: --- gcc/gimple-range-fold.cc | 3 ++- gcc/testsuite/gcc.dg/torture/pr117138.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 65d31adde54c..dcd0cae03517 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1139,7 +1139,8 @@ fold_using_range::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, || TREE_CODE_CLASS (gimple_assign_rhs_code (cond_def)) != tcc_comparison) return false; tree type = TREE_TYPE (gimple_assign_rhs1 (cond_def)); - if (!range_compatible_p (type, TREE_TYPE (gimple_assign_rhs2 (cond_def)))) + if (!value_range::supports_type_p (type) + || !range_compatible_p (type, TREE_TYPE (gimple_assign_rhs2 (cond_def)))) return false; range_op_handler hand (gimple_assign_rhs_code (cond_def)); if (!hand) diff --git a/gcc/testsuite/gcc.dg/torture/pr117138.c b/gcc/testsuite/gcc.dg/torture/pr117138.c new file mode 100644 index 000000000000..b32585d3a563 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr117138.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-msse4" { target { x86_64-*-* i?86-*-* } } } */ + +int a, b; +_Complex long c; + +void +foo () +{ + do + b = c || a; + while (a); +}