aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-10-15 10:23:06 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-10-15 11:15:25 +0200
commit28982c271cbbed3580e4c7c784892694c3b6b2de (patch)
treea2d8380ff459b2d85586a5d882cbe872f6676bfb /gcc
parent79b881df72c946f2ba61879c36ae93b0cb974617 (diff)
downloadgcc-28982c271cbbed3580e4c7c784892694c3b6b2de.zip
gcc-28982c271cbbed3580e4c7c784892694c3b6b2de.tar.gz
gcc-28982c271cbbed3580e4c7c784892694c3b6b2de.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-range-fold.cc3
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr117138.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 65d31ad..dcd0cae 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 0000000..b32585d
--- /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);
+}