Commit a8492d5e by Marc Glisse Committed by Marc Glisse

X /[ex] 4 < Y /[ex] 4

2017-04-24  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* match.pd (X/[ex]C CMP Y/[ex]C): New transformation.

gcc/testsuite/
	* gcc.dg/tree-ssa/cmpexactdiv-2.c: New file.

From-SVN: r247107
parent ec856f5f
2017-04-24 Marc Glisse <marc.glisse@inria.fr>
* match.pd (X/[ex]C CMP Y/[ex]C): New transformation.
2017-04-24 Martin Jambor <mjambor@suse.cz> 2017-04-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/80293 PR tree-optimization/80293
......
...@@ -1035,6 +1035,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ...@@ -1035,6 +1035,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& wi::neg_p (@1, TYPE_SIGN (TREE_TYPE (@1)))) && wi::neg_p (@1, TYPE_SIGN (TREE_TYPE (@1))))
(cmp @2 @0)))))) (cmp @2 @0))))))
/* X / 4 < Y / 4 iff X < Y when the division is known to be exact. */
(for cmp (simple_comparison)
(simplify
(cmp (exact_div @0 INTEGER_CST@2) (exact_div @1 @2))
(if (wi::gt_p(@2, 0, TYPE_SIGN (TREE_TYPE (@2))))
(cmp @0 @1))))
/* ((X inner_op C0) outer_op C1) /* ((X inner_op C0) outer_op C1)
With X being a tree where value_range has reasoned certain bits to always be With X being a tree where value_range has reasoned certain bits to always be
zero throughout its computed value range, zero throughout its computed value range,
......
2017-04-24 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/cmpexactdiv-2.c: New file.
2017-04-24 Volker Reichelt <v.reichelt@netcologne.de> 2017-04-24 Volker Reichelt <v.reichelt@netcologne.de>
* g++.dg/diagnostic/duplicate1.C: New test. * g++.dg/diagnostic/duplicate1.C: New test.
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized-raw" } */
int f (long *a, long *b, long *c) {
__PTRDIFF_TYPE__ l1 = b - a;
__PTRDIFF_TYPE__ l2 = c - a;
return l1 < l2;
}
/* Eventually we also want to remove all minus_expr. */
/* { dg-final { scan-tree-dump-not "exact_div_expr" "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment