mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-15 21:01:09 +08:00
Add 3 new EVRP testcases.
test new evrp functionality. gcc/testsuite/ * gcc.dg/tree-ssa/evrp20.c * gcc.dg/tree-ssa/evrp21.c * gcc.dg/tree-ssa/evrp22.c
This commit is contained in:
parent
2935ff7eb7
commit
0d1189b4e6
19
gcc/testsuite/gcc.dg/tree-ssa/evrp20.c
Normal file
19
gcc/testsuite/gcc.dg/tree-ssa/evrp20.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-evrp" } */
|
||||
|
||||
void call (void);
|
||||
|
||||
void foo (int base)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
// Ranger should be able to remove the (i > 123) comparison.
|
||||
for (i = base; i < 10; i++)
|
||||
if (i > 123)
|
||||
{
|
||||
call ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-not "call" "evrp"} } */
|
28
gcc/testsuite/gcc.dg/tree-ssa/evrp21.c
Normal file
28
gcc/testsuite/gcc.dg/tree-ssa/evrp21.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-evrp" } */
|
||||
|
||||
extern void vrp_keep (void);
|
||||
extern void vrp_kill (void);
|
||||
|
||||
void
|
||||
f2 (int s, int b)
|
||||
{
|
||||
if (s > 4)
|
||||
s = 4;
|
||||
if (s < -16)
|
||||
s = -16;
|
||||
/* s in [-16, 4]. */
|
||||
b = (b & 1) + 1;
|
||||
/* b in range [1, 2]. */
|
||||
b = s << b;
|
||||
/* b in range [-64, 16]. */
|
||||
if (b == -2)
|
||||
vrp_keep ();
|
||||
if (b <= -65)
|
||||
vrp_kill ();
|
||||
if (b >= 17)
|
||||
vrp_kill ();
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "vrp_keep \\(" 1 "evrp"} } */
|
||||
/* { dg-final { scan-tree-dump-times "vrp_kill \\(" 0 "evrp"} } */
|
43
gcc/testsuite/gcc.dg/tree-ssa/evrp22.c
Normal file
43
gcc/testsuite/gcc.dg/tree-ssa/evrp22.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* See backwards thru casts if the range fits the LHS type. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-evrp" } */
|
||||
|
||||
extern void kill(int i);
|
||||
extern void keep(int i);
|
||||
|
||||
void
|
||||
foo (int i)
|
||||
{
|
||||
if (i >= 10)
|
||||
{
|
||||
if (i <= 100)
|
||||
{
|
||||
/* i has a range of [10, 100] */
|
||||
char c = (char) i;
|
||||
if (c < 30)
|
||||
{
|
||||
/* If we wind back thru the cast with the range of c being [10,29]
|
||||
* from the branch, and recognize that the range of i fits within
|
||||
* a cast to c, then there is no missing information in a cast
|
||||
* back to int. We can use the range calculated for 'c' with 'i'
|
||||
* as well and Ranger should be able to kill the call. */
|
||||
if (i > 29)
|
||||
kill (i);
|
||||
}
|
||||
}
|
||||
/* i has a range of [10, MAX] */
|
||||
char d = (char) i;
|
||||
if (d < 30)
|
||||
{
|
||||
/* Here, a cast to a char and back is NOT equivalent, so we cannot use
|
||||
* the value of d to remove the call. */
|
||||
if (i > 29)
|
||||
keep (i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "kill \\(" 0 "evrp"} } */
|
||||
/* { dg-final { scan-tree-dump-times "keep \\(" 1 "evrp"} } */
|
||||
|
Loading…
x
Reference in New Issue
Block a user