diff options
author | Jiufu Guo <guojiufu@linux.ibm.com> | 2023-09-04 10:31:04 +0800 |
---|---|---|
committer | guojiufu <guojiufu@linux.ibm.com> | 2023-09-04 10:36:08 +0800 |
commit | 1aceceb1e2d6e86ce183c8cc448750fa03b6f79e (patch) | |
tree | d4b631ada86aafbb229a6f55ddc8429f560723f5 /gcc/tree-inline.h | |
parent | 828130772c67c94dce0757d70b4e96fb7c14ea6e (diff) | |
download | gcc-1aceceb1e2d6e86ce183c8cc448750fa03b6f79e.zip gcc-1aceceb1e2d6e86ce183c8cc448750fa03b6f79e.tar.gz gcc-1aceceb1e2d6e86ce183c8cc448750fa03b6f79e.tar.bz2 |
Optimize '(X - N * M) / N' to 'X / N - M' if valid
Integer expression "(X - N * M) / N" can be optimized to "X / N - M" with
the below conditions:
1. There is no wrap/overflow/underflow.
wrap/overflow/underflow breaks the arithmetic operation.
2. "X - N * M" and "X" are not of opposite sign.
Here, the operation "/" would be "trunc_div", the fractional part is
discarded. If "X - N * M" and "X" are in different signs, then trunc_div
discards the fractional parts (of /N) in different directions.
PR tree-optimization/108757
gcc/ChangeLog:
* match.pd ((X - N * M) / N): New pattern.
((X + N * M) / N): New pattern.
((X + C) div_rshift N): New pattern.
gcc/testsuite/ChangeLog:
* gcc.dg/pr108757-1.c: New test.
* gcc.dg/pr108757-2.c: New test.
* gcc.dg/pr108757.h: New test.
Diffstat (limited to 'gcc/tree-inline.h')
0 files changed, 0 insertions, 0 deletions