Commit 6a435314 by Wilco Dijkstra

PR71026: Canonicalize negates in division

Canonicalize x / (- y) into (-x) / y.

This moves negates out of the RHS of a division in order to
allow further simplifications and potentially more reciprocal CSEs.

2017-11-07  Wilco Dijkstra  <wdijkstr@arm.com>
	    Jackson Woodruff  <jackson.woodruff@arm.com>

    gcc/
	PR tree-optimization/71026
	* match.pd: Canonicalize negate in division.

    testsuite/
	PR 71026/tree-optimization/71026
	* gcc.dg/div_neg: New test.

From-SVN: r254497
parent 4349b15f
2017-11-07 Wilco Dijkstra <wdijkstr@arm.com>
Jackson Woodruff <jackson.woodruff@arm.com>
PR tree-optimization/71026
* match.pd: Canonicalize negate in division.
2017-11-07 Sudakshina Das <sudi.das@arm.com>
PR middle-end/80131
......@@ -354,6 +354,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(rdiv @0 (rdiv:s @1 @2))
(mult (rdiv @0 @1) @2)))
/* Simplify x / (- y) to -x / y. */
(simplify
(rdiv @0 (negate @1))
(rdiv (negate @0) @1))
/* Optimize (X & (-A)) / A where A is a power of 2, to X >> log2(A) */
(for div (trunc_div ceil_div floor_div round_div exact_div)
(simplify
......
2017-10-17 Wilco Dijkstra <wdijkstr@arm.com>
Jackson Woodruff <jackson.woodruff@arm.com>
PR tree-optimization/71026
* gcc.dg/div_neg: New test.
2017-11-07 Sudakshina Das <sudi.das@arm.com>
PR middle-end/80131
* testsuite/gcc.dg/pr80131-1.c: New Test.
* gcc.dg/pr80131-1.c: New Test.
2017-11-07 Marc Glisse <marc.glisse@inria.fr>
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
float
div_neg (float x, float y)
{
return (-x / y) * (x / -y);
}
/* { dg-final { scan-tree-dump-times " / " 1 "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