re PR tree-optimization/54471 (FAIL: gcc.dg/sms-8.c execution test)

PR tree-optimization/54471
	* tree-vrp.c (extract_range_from_binary_expr_1): For MULT_EXPR,
	don't canonicalize range if min2 is zero.

	* gcc.dg/tree-ssa/vrp86.c: New test.
	* gcc.c-torture/execute/pr54471.c: New test.

From-SVN: r193806
This commit is contained in:
Jakub Jelinek 2012-11-26 10:19:30 +01:00 committed by Jakub Jelinek
parent d42f26c16c
commit 751a243337
5 changed files with 78 additions and 2 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -1,3 +1,9 @@
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

View File

@ -0,0 +1,36 @@
/* 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;
}

View File

@ -0,0 +1,28 @@
/* 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" } } */

View File

@ -2653,7 +2653,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
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;
@ -2661,7 +2661,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
}
min2 = size - min1;
if (min2.cmp (max1, true) < 0)
if (!min2.is_zero () && min2.cmp (max1, true) < 0)
{
min1 = -min2;
max1 -= size;