aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-12-01 13:13:28 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-12-01 13:13:28 +0000
commitc306cfafefeb6e7b224cff163222c02f8def25f1 (patch)
treed3ea17e09a1dfa1353724c654fefbb3c07efba1a /gcc/match.pd
parente19740aef3f3c7c07c67e59560ef96e31e9bff96 (diff)
downloadgcc-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/match.pd')
-rw-r--r--gcc/match.pd13
1 files changed, 13 insertions, 0 deletions
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