This is a patch to fix PR49487. As Denis will be off-line for some time, it'd be great if a global reviewer would review it. It appears that he is the only AVR maintainer who approves patches.
The reason for the ICE is as explained in the PR: Rotate pattern use "X" as constraint for an operand which is used as scratch. However, the operand is a match_operand and not a match_scratch. Because the scratch is not needed in all situations, I choose to use match_scratch instead of match_operand and not to fix the constraints. Fixing constraints would lead to superfluous allocation of register if no scratch was needed. Tested with 2 FAILs less: gcc.c-torture/compile/pr46883.c ICEs without this patch and passes with it. The test case in the PR passes, too. That test case passes also the current unpatched 4.7, but it's obvious that the constraint/operand combination is a bug. Ok to commit and back-port to 4.6? Johann PR target/49487 * config/avr/avr.md (rotl<mode>3): Generate SCRATCH instead of REG. (*rotw<mode>): Use const_int_operand for operands2. Use match_scatch for operands3. (*rotb<mode>): Ditto * config/avr/avr.c (avr_rotate_bytes): Treat SCRATCH.