diff options
author | Richard Biener <rguenther@suse.de> | 2014-12-01 13:13:28 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-12-01 13:13:28 +0000 |
commit | c306cfafefeb6e7b224cff163222c02f8def25f1 (patch) | |
tree | d3ea17e09a1dfa1353724c654fefbb3c07efba1a /gcc | |
parent | e19740aef3f3c7c07c67e59560ef96e31e9bff96 (diff) | |
download | gcc-c306cfafefeb6e7b224cff163222c02f8def25f1.zip gcc-c306cfafefeb6e7b224cff163222c02f8def25f1.tar.gz gcc-c306cfafefeb6e7b224cff163222c02f8def25f1.tar.bz2 |
re PR tree-optimization/15346 ([tree-ssa] combine two successive divisions)
2014-12-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/15346
* Makefile.in (gimple-match.o-warn): Remove -Wno-unused-parameter,
add -Wno-unused-but-set-variable.
* match.pd: Combine two successive divisions.
* gcc.dg/tree-ssa/forwprop-32.c: New testcase.
From-SVN: r218211
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/Makefile.in | 4 | ||||
-rw-r--r-- | gcc/match.pd | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/forwprop-32.c | 18 |
5 files changed, 45 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d696865..ae3b3c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2014-12-01 Richard Biener <rguenther@suse.de> + PR tree-optimization/15346 + * Makefile.in (gimple-match.o-warn): Remove -Wno-unused-parameter, + add -Wno-unused-but-set-variable. + * match.pd: Combine two successive divisions. + +2014-12-01 Richard Biener <rguenther@suse.de> + PR middle-end/64126 * match.pd: Allow conversions in ~A + 1 -> -A, add -A - 1 -> ~A and -1 - A -> ~A. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 49f94e7..d36b2f0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -209,8 +209,8 @@ gengtype-lex.o-warn = -Wno-error libgcov-util.o-warn = -Wno-error libgcov-driver-tool.o-warn = -Wno-error libgcov-merge-tool.o-warn = -Wno-error -gimple-match.o-warn = -Wno-unused-variable -Wno-unused-parameter -generic-match.o-warn = -Wno-unused-variable -Wno-unused-parameter +gimple-match.o-warn = -Wno-unused-variable -Wno-unused-but-set-variable +generic-match.o-warn = -Wno-unused-variable -Wno-unused-but-set-variable # All warnings have to be shut off in stage1 if the compiler used then # isn't gcc; configure determines that. WARN_CFLAGS will be either diff --git a/gcc/match.pd b/gcc/match.pd index 42e7c62..ee9bbc6 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -129,6 +129,19 @@ along with GCC; see the file COPYING3. If not see && TYPE_UNSIGNED (type)) (trunc_div @0 @1))) +/* Combine two successive divisions. */ +(for div (trunc_div ceil_div floor_div round_div exact_div) + (simplify + (div (div @0 INTEGER_CST@1) INTEGER_CST@2) + (with { + bool overflow_p; + wide_int mul = wi::mul (@1, @2, TYPE_SIGN (type), &overflow_p); + } + (if (!overflow_p) + (div @0 { wide_int_to_tree (type, mul); })) + (if (overflow_p) + { build_zero_cst (type); })))) + /* Optimize A / A to 1.0 if we don't care about NaNs or Infinities. */ (simplify diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb8bef7..e56f3d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-01 Richard Biener <rguenther@suse.de> + + PR tree-optimization/15346 + * gcc.dg/tree-ssa/forwprop-32.c: New testcase. + 2014-12-01 Yuri Rumyantsev <ysrumyan@gmail.com> PR tree-optimization/63941 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-32.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-32.c new file mode 100644 index 0000000..93851a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-32.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-forwprop1 -fdump-tree-ccp1" } */ + +int foo (int x) +{ + int tem = x / 3; + return tem / 5; +} +int bar (int x) +{ + int tem = x / 3; + return tem / (__INT_MAX__ / 2); +} + +/* { dg-final { scan-tree-dump "x_.\\(D\\) / 15" "forwprop1" } } */ +/* { dg-final { scan-tree-dump "return 0;" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "forwprop1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ |