diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2017-05-25 10:50:54 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2017-05-25 08:50:54 +0000 |
commit | bce8ef718dcafd0251fe338bf952679b803493c3 (patch) | |
tree | 0084056ebea292b4231b2a4593846aa7b7366cc9 | |
parent | 11d6b45d431b0aa30cf5ce3941b01ba4fd342af5 (diff) | |
download | gcc-bce8ef718dcafd0251fe338bf952679b803493c3.zip gcc-bce8ef718dcafd0251fe338bf952679b803493c3.tar.gz gcc-bce8ef718dcafd0251fe338bf952679b803493c3.tar.bz2 |
Relax VIEW_CONVERT_EXPR - CONVERT_EXPR combination
2017-05-25 Marc Glisse <marc.glisse@inria.fr>
gcc/
* match.pd (view_convert (convert@0 @1)): Handle zero-extension.
gcc/testsuite/
* gcc.dg/tree-ssa/vce-1.c: New file.
From-SVN: r248449
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/match.pd | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vce-1.c | 14 |
4 files changed, 28 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf75376..1da0405 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2017-05-25 Marc Glisse <marc.glisse@inria.fr> + * match.pd (view_convert (convert@0 @1)): Handle zero-extension. + +2017-05-25 Marc Glisse <marc.glisse@inria.fr> + * match.pd ((A +- CST1) +- CST2): Allow some conversions. * tree.c (drop_tree_overflow): Handle COMPLEX_CST and VECTOR_CST. diff --git a/gcc/match.pd b/gcc/match.pd index 77271a0..b5e5a98 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1856,13 +1856,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (@0))) (convert @0))) -/* Strip inner integral conversions that do not change precision or size. */ +/* Strip inner integral conversions that do not change precision or size, or + zero-extend while keeping the same size (for bool-to-char). */ (simplify (view_convert (convert@0 @1)) (if ((INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@0))) && (INTEGRAL_TYPE_P (TREE_TYPE (@1)) || POINTER_TYPE_P (TREE_TYPE (@1))) - && (TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (TREE_TYPE (@1))) - && (TYPE_SIZE (TREE_TYPE (@0)) == TYPE_SIZE (TREE_TYPE (@1)))) + && TYPE_SIZE (TREE_TYPE (@0)) == TYPE_SIZE (TREE_TYPE (@1)) + && (TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (TREE_TYPE (@1)) + || (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (TREE_TYPE (@1)) + && TYPE_UNSIGNED (TREE_TYPE (@1))))) (view_convert @1))) /* Re-association barriers around constants and other re-association diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index efe1dcb..bb65818 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2017-05-25 Marc Glisse <marc.glisse@inria.fr> + * gcc.dg/tree-ssa/vce-1.c: New file. + +2017-05-25 Marc Glisse <marc.glisse@inria.fr> + * gcc.dg/tree-ssa/addadd.c: New file. 2017-05-24 Nathan Sidwell <nathan@acm.org> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vce-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vce-1.c new file mode 100644 index 0000000..dbaf02e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vce-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef struct { _Bool b; } A; +_Bool f(double u){ + A a; + if(u==0) + a.b=1; + else + a.b=0; + return a.b; +} + +/* { dg-final { scan-tree-dump-not "VIEW_CONVERT_EXPR" "optimized" } } */ |