Bug 72767 - [avr] Some branches report too small insn length
Summary: [avr] Some branches report too small insn length
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.4.0
: P4 normal
Target Milestone: 5.4
Assignee: Georg-Johann Lay
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-01 12:32 UTC by Georg-Johann Lay
Modified: 2016-08-01 12:46 UTC (History)
0 users

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
nops.c: C test case (175 bytes, text/plain)
2016-08-01 12:32 UTC, Georg-Johann Lay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2016-08-01 12:32:07 UTC
Created attachment 39039 [details]
nops.c: C test case

Some branch instructions report too small instruction length which might lead to problems if other branches crossing the critical ones use a wrong instruction sequence.  Outcome can be "relocation truncted to fit" error from the linker.

Compile test case with

$ avr-gcc -S -dp -Os -mmcu=atmega16 nops.c

In bra_63 there is (should be "length = 2"):

	brne .+2	 ;  7	branch	[length = 1]
	rjmp .L1

In bra_2045 (should be "length = 3"):

	brne .+4	 ;  7	branch	[length = 2]
	jmp .L6
Comment 1 Georg-Johann Lay 2016-08-01 12:36:43 UTC
Author: gjl
Date: Mon Aug  1 12:36:11 2016
New Revision: 238948

URL: https://gcc.gnu.org/viewcvs?rev=238948&root=gcc&view=rev
Log:
	PR target/72767
	* config/avr/avr.md (length) [branch]: Correct insn length
	attribute for forward branches.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.md
Comment 2 Georg-Johann Lay 2016-08-01 12:41:12 UTC
Author: gjl
Date: Mon Aug  1 12:40:41 2016
New Revision: 238949

URL: https://gcc.gnu.org/viewcvs?rev=238949&root=gcc&view=rev
Log:
	Backport from 2016-08-01 trunk r238948.
	PR target/72767
	* config/avr/avr.md (length) [branch]: Correct insn length
	attribute for forward branches.


Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/config/avr/avr.md
Comment 3 Georg-Johann Lay 2016-08-01 12:44:50 UTC
Author: gjl
Date: Mon Aug  1 12:44:18 2016
New Revision: 238950

URL: https://gcc.gnu.org/viewcvs?rev=238950&root=gcc&view=rev
Log:
	Backport from 2016-08-01 trunk r238948.
	PR target/72767
	* config/avr/avr.md (length) [branch]: Correct insn length
	attribute for forward branches.


Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/config/avr/avr.md
Comment 4 Georg-Johann Lay 2016-08-01 12:46:33 UTC
Fixed for 5.5 and 6.2+.