mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-19 09:05:17 +08:00
Generalize a<b&a<c -> a<min(b,c)
2018-05-01 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/85143 gcc/ * match.pd (A<B&A<C): Extend to BIT_IOR_EXPR. gcc/testsuite/ * gcc.dg/tree-ssa/minmax-loopend.c: Extend and split... * gcc.dg/tree-ssa/minmax-loopend-2.c: ... here. From-SVN: r259812
This commit is contained in:
parent
5052a74c45
commit
dac920e8c8
@ -1,3 +1,8 @@
|
||||
2018-05-01 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
PR tree-optimization/85143
|
||||
* match.pd (A<B&A<C): Extend to BIT_IOR_EXPR.
|
||||
|
||||
2018-05-01 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR lto/85451
|
||||
|
@ -4514,10 +4514,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
||||
|
||||
/* Transform (@0 < @1 and @0 < @2) to use min,
|
||||
(@0 > @1 and @0 > @2) to use max */
|
||||
(for op (lt le gt ge)
|
||||
ext (min min max max)
|
||||
(for logic (bit_and bit_and bit_and bit_and bit_ior bit_ior bit_ior bit_ior)
|
||||
op (lt le gt ge lt le gt ge )
|
||||
ext (min min max max max max min min )
|
||||
(simplify
|
||||
(bit_and (op:cs @0 @1) (op:cs @0 @2))
|
||||
(logic (op:cs @0 @1) (op:cs @0 @2))
|
||||
(if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
|
||||
&& TREE_CODE (@0) != INTEGER_CST)
|
||||
(op @0 (ext @1 @2)))))
|
||||
|
@ -1,3 +1,9 @@
|
||||
2018-05-01 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
PR tree-optimization/85143
|
||||
* gcc.dg/tree-ssa/minmax-loopend.c: Extend and split...
|
||||
* gcc.dg/tree-ssa/minmax-loopend-2.c: ... here.
|
||||
|
||||
2018-05-01 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
PR c/84258
|
||||
|
16
gcc/testsuite/gcc.dg/tree-ssa/minmax-loopend-2.c
Normal file
16
gcc/testsuite/gcc.dg/tree-ssa/minmax-loopend-2.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||
|
||||
int and_test(long a, long b, long c) {
|
||||
int cmp1 = a > b;
|
||||
int cmp2 = a > c;
|
||||
return cmp1 & cmp2;
|
||||
}
|
||||
|
||||
int ior_test (long a, long b, long c) {
|
||||
int cmp1 = a < b;
|
||||
int cmp2 = a < c;
|
||||
return cmp1 | cmp2;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */
|
@ -1,17 +1,16 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||
|
||||
int min_test(long a, long b, long c) {
|
||||
int and_test(long a, long b, long c) {
|
||||
int cmp1 = a < b;
|
||||
int cmp2 = a < c;
|
||||
return cmp1 & cmp2;
|
||||
}
|
||||
|
||||
int max_test (long a, long b, long c) {
|
||||
int ior_test (long a, long b, long c) {
|
||||
int cmp1 = a > b;
|
||||
int cmp2 = a > c;
|
||||
return cmp1 & cmp2;
|
||||
return cmp1 | cmp2;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */
|
||||
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */
|
||||
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */
|
||||
|
Loading…
Reference in New Issue
Block a user