Skip to content
Snippets Groups Projects
Commit 8d01bc7d authored by Richard Sandiford's avatar Richard Sandiford
Browse files

Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule

match.pd had a rule to simplify ((X /[ex] A) +- B) * A -> X +- A * B
when A and B are INTEGER_CSTs.  This patch extends it to handle the
case where the outer multiplication is by a factor of A, not just
A itself.  It also handles addition and multiplication of poly_ints.
(Exact division by a poly_int seems unlikely.)

gcc/
	* match.pd: Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule
	to ((X /[ex] C1) +- C2) * (C1 * C3) -> (X * C3) +- (C1 * C2 * C3).

gcc/testsuite/
	* gcc.dg/tree-ssa/mulexactdiv-5.c: New test.
	* gcc.dg/tree-ssa/mulexactdiv-6.c: Likewise.
	* gcc.dg/tree-ssa/mulexactdiv-7.c: Likewise.
	* gcc.dg/tree-ssa/mulexactdiv-8.c: Likewise.
	* gcc.target/aarch64/sve/cnt_fold_3.c: Likewise.
parent b381e84c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment