]> git.ipfire.org Git - thirdparty/gcc.git/commit
Generalise ((X /[ex] A) +- B) * A -> X +- A * B rule
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 24 Oct 2024 13:22:32 +0000 (14:22 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 24 Oct 2024 13:22:32 +0000 (14:22 +0100)
commit8d01bc7dc453a44cd5b1913fb8a4104ee56fa410
treea2705980ff0efadd28b6a19f3c16c23d92f92fc2
parentb381e84c4ecd72029effe1f8919d3aaea0fbd86b
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.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cnt_fold_3.c [new file with mode: 0644]