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.
|| 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)
--- /dev/null
+/* { 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);
+}