]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/loop-doloop.c
Fold (add -1; zero_ext; add +1) operations to zero_ext when not overflow(PR37451...
authorXionghu Luo <luoxhu@linux.ibm.com>
Fri, 15 May 2020 02:03:24 +0000 (21:03 -0500)
committerXionghu Luo <luoxhu@linux.ibm.com>
Fri, 15 May 2020 02:06:50 +0000 (21:06 -0500)
commit8a15faa730f99100f6f3ed12663563356ec5a2c0
tree534a282a2cf01a9b3f1dca437eb0480bfa5aefd7
parent98aad12cd2e618286a36fed9bc870f19bdbc0f07
Fold (add -1; zero_ext; add +1) operations to zero_ext when not overflow(PR37451, PR61837)

This "subtract/extend/add" existed for a long time and still annoying us
(PR37451, part of PR61837) when converting from 32bits to 64bits, as the ctr
register is used as 64bits on powerpc64, Andraw Pinski had a patch but
caused some issue and reverted by Joseph S. Myers(PR37451, PR37782).

Andraw:
http://gcc.gnu.org/ml/gcc-patches/2008-09/msg01070.html
http://gcc.gnu.org/ml/gcc-patches/2008-10/msg01321.html
Joseph:
https://gcc.gnu.org/legacy-ml/gcc-patches/2011-11/msg02405.html

We still can do the simplification from "subtract/zero_ext/add" to "zero_ext"
when loop iterations is known to be LT than MODE_MAX (only do simplify
when counter+0x1 NOT overflow).

Bootstrap and regression tested pass on Power8-LE.

gcc/ChangeLog

2020-05-15  Xiong Hu Luo  <luoxhu@linux.ibm.com>

PR rtl-optimization/37451, part of PR target/61837
* loop-doloop.c (doloop_simplify_count): New function.  Simplify
(add -1; zero_ext; add +1) to zero_ext when not wrapping.
(doloop_modify): Call doloop_simplify_count.

gcc/testsuite/ChangeLog

2020-05-15  Xiong Hu Luo  <luoxhu@linux.ibm.com>

PR rtl-optimization/37451, part of PR target/61837
* gcc.target/powerpc/doloop-2.c: New test.
gcc/ChangeLog
gcc/loop-doloop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/doloop-2.c [new file with mode: 0644]