match.pd ((convert1 (minmax ((convert2 (x) c)))) -> minmax (x c)): New pattern.
* match.pd ((convert1 (minmax ((convert2 (x) c)))) -> minmax (x c)): New pattern. gcc/testsuite * gcc.dg/fold-convmaxconv-1.c: New test. * gcc.dg/fold-convminconv-1.c: New test. From-SVN: r241612
This commit is contained in:
parent
fe14572b1a
commit
ad6e4ba8de
5 changed files with 51 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-10-27 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
* match.pd ((convert1 (minmax ((convert2 (x) c)))) -> minmax (x c)):
|
||||
New pattern.
|
||||
|
||||
2016-10-26 Kelvin Nilsen <kelvin@gcc.gnu.org>
|
||||
|
||||
PR target/78056
|
||||
|
|
11
gcc/match.pd
11
gcc/match.pd
|
@ -1337,6 +1337,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
|||
&& TYPE_MIN_VALUE (type)
|
||||
&& operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
|
||||
@0)))
|
||||
|
||||
/* (convert (minmax ((convert (x) c)))) -> minmax (x c) if x is promoted
|
||||
and the outer convert demotes the expression back to x's type. */
|
||||
(for minmax (min max)
|
||||
(simplify
|
||||
(convert (minmax@0 (convert @1) INTEGER_CST@2))
|
||||
(if (types_match (@1, type) && int_fits_type_p (@2, type)
|
||||
&& TYPE_SIGN (TREE_TYPE (@0)) == TYPE_SIGN (type)
|
||||
&& TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type))
|
||||
(minmax @1 (convert @2)))))
|
||||
|
||||
(for minmax (FMIN FMAX)
|
||||
/* If either argument is NaN, return the other one. Avoid the
|
||||
transformation if we get (and honor) a signalling NaN. */
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2016-10-27 Bin Cheng <bin.cheng@arm.com>
|
||||
|
||||
* gcc.dg/fold-convmaxconv-1.c: New test.
|
||||
* gcc.dg/fold-convminconv-1.c: New test.
|
||||
|
||||
2016-10-26 Steven G. Kargl <kargl@gcc.gnu.org>
|
||||
|
||||
PR fortran/78092
|
||||
|
|
15
gcc/testsuite/gcc.dg/fold-convmaxconv-1.c
Normal file
15
gcc/testsuite/gcc.dg/fold-convmaxconv-1.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-optimized" } */
|
||||
|
||||
int foo (short a[], int x)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
x = a[i];
|
||||
a[i] = (x <= 0 ? 0 : x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-not " = MAX_EXPR <x_\[0-9\]*" "optimized" } } */
|
15
gcc/testsuite/gcc.dg/fold-convminconv-1.c
Normal file
15
gcc/testsuite/gcc.dg/fold-convminconv-1.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-optimized" } */
|
||||
|
||||
int foo (unsigned short a[], unsigned int x)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
x = a[i];
|
||||
a[i] = (x >= 255 ? 255 : x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-not " = MIN_EXPR <x_\[0-9\]*" "optimized" } } */
|
Loading…
Add table
Reference in a new issue