diff mbox series

tree-optimization/117138 - fix ICE with vector comparison in COND_EXPR

Message ID 20241015082753.C0B073858D26@sourceware.org
State New
Headers show
Series tree-optimization/117138 - fix ICE with vector comparison in COND_EXPR | expand

Commit Message

Richard Biener Oct. 15, 2024, 8:27 a.m. UTC
The range folding code of COND_EXPRs missed a check whether the
comparison operand type is supported.

Bootstrap and regtest in progress on x86_64-unknown-linux-gnu.  I'll
push if that succeeds.  There might be other places missing such
a check, not sure.

Richard.

	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.
---
 gcc/gimple-range-fold.cc                |  3 ++-
 gcc/testsuite/gcc.dg/torture/pr117138.c | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr117138.c
diff mbox series

Patch

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 65d31adde54..dcd0cae0351 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 00000000000..b32585d3a56
--- /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);
+}