===================================================================
@@ -384,10 +384,10 @@ emit_case_bit_tests (gimple swtch, tree
gsi = gsi_last_bb (switch_bb);
- /* idx = (unsigned) (x - minval) */
- idx = fold_build2 (MINUS_EXPR, index_type, index_expr,
- fold_convert (index_type, minval));
- idx = fold_convert (unsigned_index_type, idx);
+ /* idx = (unsigned)x - minval */
+ idx = fold_convert (unsigned_index_type, index_expr);
+ idx = fold_build2 (MINUS_EXPR, unsigned_index_type, idx,
+ fold_convert (unsigned_index_type, minval));
idx = force_gimple_operand_gsi (&gsi, idx,
/*simple=*/true, NULL_TREE,
/*before=*/true, GSI_SAME_STMT);
===================================================================
@@ -0,0 +1,34 @@
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+/* Based on f3 from vrp63.c, but with switch instead of if-chain. */
+
+extern void link_error (void);
+
+void
+f3 (int s)
+{
+ if (s >> 3 == -2)
+ /* s in range [ -16, -9]. */
+ ;
+ else
+ {
+ /* s in range ~[-16, -9], so none of the case labels can be taken. */
+ switch (s)
+ {
+ case -16:
+ case -12:
+ case -9:
+ link_error ();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+int
+main ()
+{
+ return 0;
+}