diff options
author | Alexander Monakov <amonakov@gcc.gnu.org> | 2017-07-25 17:33:39 +0300 |
---|---|---|
committer | Alexander Monakov <amonakov@gcc.gnu.org> | 2017-07-25 17:33:39 +0300 |
commit | b771c60914096866b6e8c2fa9b953b471e22708c (patch) | |
tree | dcd6f6ff1120d626198f1b8910da526b1b57b890 | |
parent | 417ca0117a1a9a8aaf5bc5ca530adfd68cb00399 (diff) | |
download | gcc-b771c60914096866b6e8c2fa9b953b471e22708c.zip gcc-b771c60914096866b6e8c2fa9b953b471e22708c.tar.gz gcc-b771c60914096866b6e8c2fa9b953b471e22708c.tar.bz2 |
match.pd: reassociate multiplications
* match.pd ((X * CST) * Y): Reassociate to (X * Y) * CST.
testsuite/
* gcc.dg/tree-ssa/assoc-2.c: New testcase.
From-SVN: r250523
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/match.pd | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c | 8 |
4 files changed, 26 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 242d89d..654227c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,8 @@ -2017-07-07 Torsten Duwe <duwe@suse.de> +2017-07-25 Alexander Monakov <amonakov@ispras.ru> + + * match.pd ((X * CST) * Y): Reassociate to (X * Y) * CST. + +2017-07-25 Torsten Duwe <duwe@suse.de> * common.opt: Introduce -fpatchable-function-entry command line option, and its variables function_entry_patch_area_size diff --git a/gcc/match.pd b/gcc/match.pd index 7f5807c..39e1e5c 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2213,6 +2213,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (mult @0 integer_minus_onep) (negate @0)) +/* Reassociate (X * CST) * Y to (X * Y) * CST. This does not introduce + signed overflow for CST != 0 && CST != -1. */ +(simplify + (mult:c (mult:s @0 INTEGER_CST@1) @2) + (if (TREE_CODE (@2) != INTEGER_CST + && !integer_zerop (@1) && !integer_minus_onep (@1)) + (mult (mult @0 @2) @1))) + /* True if we can easily extract the real and imaginary parts of a complex number. */ (match compositional_complex diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8515ed..a5c00b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,8 @@ -2017-07-07 Torsten Duwe <duwe@suse.de> +2017-07-25 Alexander Monakov <amonakov@ispras.ru> + + * gcc.dg/tree-ssa/assoc-2.c: New testcase. + +2017-07-25 Torsten Duwe <duwe@suse.de> * c-c++-common/patchable_function_entry-default.c: New test. * c-c++-common/patchable_function_entry-decl.c: Likewise. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c b/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c new file mode 100644 index 0000000..a92c882 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-gimple-raw -fdump-tree-optimized-raw" } */ + +int f0(int a, int b){ + return a * 33 * b * 55; +} + +/* { dg-final { scan-tree-dump-times "mult_expr" 2 "gimple" } } */ |