[AArch64] PR target/84748: Mark *compare_cstore<mode>_insn as clobbering CC reg
commit0d0b6c21f5470ca566ecd175736a48c84f7e3983
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Mar 2018 15:50:25 +0000 (8 15:50 +0000)
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Mar 2018 15:50:25 +0000 (8 15:50 +0000)
tree005276771a440d1d92a8b12943f3a1ea917fe037
parent307f73ba125cdb239ac62881ab79d6b09ca51aa7
[AArch64] PR target/84748: Mark *compare_cstore<mode>_insn as clobbering CC reg

In this wrong-code PR the combine pass ends up moving a CC-using instruction past a *compare_cstore<mode>_insn
insn_and_split. After reload the *compare_cstore<mode>_insn splitter ends up generating a SUBS instruction that
clobbers the condition flags, and things go bad.

The solution is simple, the *compare_cstore<mode>_insn pattern should specify that it clobbers the CC register
so that combine (or any other pass) does not assume that it can move CC-using patterns across it.

This patch does that and fixes the testcase.

The testcase FAILs on GCC 8 only, but the buggy pattern is in GCC 6 onwards, so we should backport this as
a latent bug fix after it's had some time to bake in trunk.

Bootstrapped and tested on aarch64-none-linux-gnu.

PR target/84748
* config/aarch64/aarch64.md (*compare_cstore<mode>_insn): Mark pattern
as clobbering CC_REGNUM.

* gcc.c-torture/execute/pr84748.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258366 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr84748.c [new file with mode: 0644]