* [patch,avr] Adjust insn length of forward branches.
@ 2016-08-01 7:56 Georg-Johann Lay
2016-08-01 11:52 ` Denis Chertykov
0 siblings, 1 reply; 2+ messages in thread
From: Georg-Johann Lay @ 2016-08-01 7:56 UTC (permalink / raw)
To: gcc-patches; +Cc: Denis Chertykov
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]
The length computation of "branch" flavour insn length attribute computed a
length one instruction too short, e.g. in the following test case:
#define N0(N) if (X++ < N) __builtin_avr_nop()
#define N1(N) N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N)
#define N2(N) N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N)
#define N3(N) N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N)
#define N4(N) N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N)
void bra_63 (unsigned char x)
{
if (x > 0)
{
unsigned X = 0;
N4 (63);
}
}
void bra_2045 (unsigned char x)
{
if (x > 0)
{
unsigned X = 0;
N4 (2045);
}
}
when compiled for MCU with JMP instruction like -mmcu=atmega168
Ok to apply?
Johann
* config/avr/avr.md (length) [branch]: Correct insn length
attribute for forward branches.
[-- Attachment #2: branch-len.diff --]
[-- Type: text/x-patch, Size: 1001 bytes --]
Index: config/avr/avr.md
===================================================================
--- config/avr/avr.md (revision 238871)
+++ config/avr/avr.md (working copy)
@@ -112,12 +112,12 @@ (define_attr "type" "branch,branch1,arit
(define_attr "length" ""
(cond [(eq_attr "type" "branch")
(if_then_else (and (ge (minus (pc) (match_dup 0))
- (const_int -63))
+ (const_int -62))
(le (minus (pc) (match_dup 0))
(const_int 62)))
(const_int 1)
(if_then_else (and (ge (minus (pc) (match_dup 0))
- (const_int -2045))
+ (const_int -2044))
(le (minus (pc) (match_dup 0))
(const_int 2045)))
(const_int 2)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch,avr] Adjust insn length of forward branches.
2016-08-01 7:56 [patch,avr] Adjust insn length of forward branches Georg-Johann Lay
@ 2016-08-01 11:52 ` Denis Chertykov
0 siblings, 0 replies; 2+ messages in thread
From: Denis Chertykov @ 2016-08-01 11:52 UTC (permalink / raw)
To: Georg-Johann Lay; +Cc: gcc-patches
2016-08-01 10:56 GMT+03:00 Georg-Johann Lay <avr@gjlay.de>:
> The length computation of "branch" flavour insn length attribute computed a
> length one instruction too short, e.g. in the following test case:
>
> #define N0(N) if (X++ < N) __builtin_avr_nop()
>
> #define N1(N) N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N);N0(N)
> #define N2(N) N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N);N1(N)
> #define N3(N) N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N);N2(N)
> #define N4(N) N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N);N3(N)
>
> void bra_63 (unsigned char x)
> {
> if (x > 0)
> {
> unsigned X = 0;
> N4 (63);
> }
> }
>
> void bra_2045 (unsigned char x)
> {
> if (x > 0)
> {
> unsigned X = 0;
> N4 (2045);
> }
> }
>
> when compiled for MCU with JMP instruction like -mmcu=atmega168
>
> Ok to apply?
>
> Johann
>
>
> * config/avr/avr.md (length) [branch]: Correct insn length
> attribute for forward branches.
Please apply.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-01 11:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 7:56 [patch,avr] Adjust insn length of forward branches Georg-Johann Lay
2016-08-01 11:52 ` Denis Chertykov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).