PR tree-optimization/96967
* tree-vrp.c (find_case_label_range): Cast label range to
type of switch operand.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fshort-enums" } */
+
+enum re {
+ o3,
+};
+
+int
+uj (int mq, enum re dn)
+{
+ enum re nr = mq;
+
+ switch (nr)
+ {
+ case 4:
+ if (dn == 0)
+ goto wdev_inactive_unlock;
+ break;
+
+ default:
+ break;
+ }
+
+ switch (nr)
+ {
+ case 0:
+ case 4:
+ return 0;
+
+ default:
+ break;
+ }
+
+ wdev_inactive_unlock:
+ return 1;
+}
tree case_high
= CASE_HIGH (label) ? CASE_HIGH (label) : CASE_LOW (label);
int_range_max label_range (CASE_LOW (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 == *range_of_op)
return label;