+2016-12-16 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/78819
+ * tree-vrp.c (find_switch_asserts): Return if the insertion limit is 0.
+ Don't register an assertion if the default case shares a label with
+ another case.
+
2016-12-16 Wilco Dijkstra <wdijkstr@arm.com>
* config/arm/arm.md (subsi3_carryin): Add Thumb-2 RSC #0.
+2016-12-16 Marek Polacek <polacek@redhat.com>
+
+ PR tree-optimization/78819
+ * gcc.dg/tree-ssa/vrp112.c: New test.
+
2016-12-16 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt61.adb: New test.
--- /dev/null
+/* PR tree-optimization/78819 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+__attribute__((noinline, noclone)) void
+foo (int argc)
+{
+ if (argc <= 0 || argc > 3)
+ return;
+
+ switch (argc)
+ {
+ case 1:
+ case 3:
+ if (argc != 3)
+ __builtin_abort ();
+ break;
+ case 2:
+ asm ("");
+ break;
+ default:
+ __builtin_abort ();
+ }
+}
+
+int
+main (void)
+{
+ foo (3);
+ return 0;
+}
/* Now register along the default label assertions that correspond to the
anti-range of each label. */
int insertion_limit = PARAM_VALUE (PARAM_MAX_VRP_SWITCH_ASSERTIONS);
+ if (insertion_limit == 0)
+ return;
+
+ /* We can't do this if the default case shares a label with another case. */
+ tree default_cl = gimple_switch_default_label (last);
for (idx = 1; idx < n; idx++)
{
tree min, max;
tree cl = gimple_switch_label (last, idx);
+ if (CASE_LABEL (cl) == CASE_LABEL (default_cl))
+ continue;
min = CASE_LOW (cl);
max = CASE_HIGH (cl);
{
tree next_min, next_max;
tree next_cl = gimple_switch_label (last, idx);
+ if (CASE_LABEL (next_cl) == CASE_LABEL (default_cl))
+ break;
next_min = CASE_LOW (next_cl);
next_max = CASE_HIGH (next_cl);