+2012-11-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/54471
+ * tree-vrp.c (extract_range_from_binary_expr_1): For MULT_EXPR,
+ don't canonicalize range if min2 is zero.
+
2012-11-26 Hans-Peter Nilsson <hp@bitrange.com>
PR middle-end/55030
+2012-11-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/54471
+ * gcc.dg/tree-ssa/vrp86.c: New test.
+ * gcc.c-torture/execute/pr54471.c: New test.
+
2012-11-26 Hans-Peter Nilsson <hp@bitrange.com>
PR middle-end/55030
--- /dev/null
+/* PR tree-optimization/54471 */
+
+#ifdef __SIZEOF_INT128__
+#define T __int128
+#else
+#define T long long
+#endif
+
+extern void abort (void);
+
+__attribute__ ((noinline))
+unsigned T
+foo (T ixi, unsigned ctr)
+{
+ unsigned T irslt = 1;
+ T ix = ixi;
+
+ for (; ctr; ctr--)
+ {
+ irslt *= ix;
+ ix *= ix;
+ }
+
+ if (irslt != 14348907)
+ abort ();
+ return irslt;
+}
+
+int
+main ()
+{
+ unsigned T res;
+
+ res = foo (3, 4);
+ return 0;
+}
--- /dev/null
+/* PR tree-optimization/54471 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+#ifdef __SIZEOF_INT128__
+#define T __int128
+#else
+#define T long long
+#endif
+
+void fn1call (void);
+void fn2call (void);
+
+void
+foo (unsigned T x)
+{
+ if (x > (unsigned T) -3)
+ return;
+ unsigned T y = 2 * x;
+ if (y == 42)
+ fn1call ();
+ else
+ fn2call ();
+}
+
+/* { dg-final { scan-tree-dump "fn1call" "vrp1"} } */
+/* { dg-final { scan-tree-dump "fn2call" "vrp1"} } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
if (TYPE_UNSIGNED (expr_type))
{
double_int min2 = size - min0;
- if (min2.cmp (max0, true) < 0)
+ if (!min2.is_zero () && min2.cmp (max0, true) < 0)
{
min0 = -min2;
max0 -= size;
}
min2 = size - min1;
- if (min2.cmp (max1, true) < 0)
+ if (!min2.is_zero () && min2.cmp (max1, true) < 0)
{
min1 = -min2;
max1 -= size;