PR tree-optimization/96818
* tree-vrp.c (find_case_label_range): Cast label range to
type of switch operand.
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2" }
+
+bool operatorY ();
+
+struct l
+{
+ int m;
+ int k;
+ void n ();
+ l ()
+ {
+ while (operatorY ())
+ switch ((unsigned char) k)
+ case 0:
+ {
+ n ();
+ case 1:if (m)
+ ;
+ }
+ }
+};
+
+void
+p ()
+{
+ l ();
+}
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2" }
+
+int a, b, c;
+void d() {
+ unsigned short e;
+ while (b)
+ ;
+ e = (e + 5) / a;
+ switch (e)
+ case 0:
+ case 3:
+ c = a;
+}
if (!case_high)
case_high = CASE_LOW (max_label);
widest_irange label_range (CASE_LOW (min_label), case_high);
+ if (!types_compatible_p (label_range.type (), range_of_op->type ()))
+ range_cast (label_range, range_of_op->type ());
label_range.intersect (range_of_op);
if (label_range.undefined_p ())
return gimple_switch_label (switch_stmt, 0);