diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2024-10-03 09:34:08 +0200 |
---|---|---|
committer | Georg-Johann Lay <avr@gjlay.de> | 2024-10-04 20:28:12 +0200 |
commit | 58b9024c996951f8d768f1c83a74e5f3eef8a1c7 (patch) | |
tree | 3fbad7a6a2b2aae2c28edbf65f068321526ac1f9 | |
parent | 0f39769ab39ba74c9890c1553c016469c043965c (diff) | |
download | gcc-58b9024c996951f8d768f1c83a74e5f3eef8a1c7.zip gcc-58b9024c996951f8d768f1c83a74e5f3eef8a1c7.tar.gz gcc-58b9024c996951f8d768f1c83a74e5f3eef8a1c7.tar.bz2 |
AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.
PR target/116953
gcc/
* config/avr/avr.cc (avr_out_sbxx_branch): Work on a copy of
the operands rather than on operands itself, which is just
recog_data.operand and may be clobbered by jump_over_one_insn_p.
gcc/testsuite/
* gcc.target/avr/torture/pr116953.c: New test.
-rw-r--r-- | gcc/config/avr/avr.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/avr/torture/pr116953.c | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 92013c3..735d05b 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -13603,8 +13603,12 @@ avr_hard_regno_rename_ok (unsigned int old_reg, unsigned int new_reg) Operand 3: label to jump to if the test is true. */ const char * -avr_out_sbxx_branch (rtx_insn *insn, rtx operands[]) +avr_out_sbxx_branch (rtx_insn *insn, rtx xop[]) { + // jump_over_one_insn_p may call extract on the next insn, clobbering + // recog_data.operand. Hence make a copy of the operands (PR116953). + rtx operands[] = { xop[0], xop[1], xop[2], xop[3] }; + rtx_code comp = GET_CODE (operands[0]); bool long_jump = get_attr_length (insn) >= 4; bool reverse = long_jump || jump_over_one_insn_p (insn, operands[3]); diff --git a/gcc/testsuite/gcc.target/avr/torture/pr116953.c b/gcc/testsuite/gcc.target/avr/torture/pr116953.c new file mode 100644 index 0000000..f8e5a38 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr116953.c @@ -0,0 +1,7 @@ +unsigned foo (unsigned x, unsigned y) +{ + int i; + for (i = 8; i--; x <<= 1) + y ^= (x ^ y) & 0x80 ? 79U : 0U; + return y; +} |