Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.arch / Re: Variable branch length encoding?

SubjectAuthor
* Variable branch length encoding?Terje Mathisen
+- Re: Variable branch length encoding?Quadibloc
+* Re: Variable branch length encoding?EricP
|+* Re: Variable branch length encoding?Stephen Fuld
||+* Re: Variable branch length encoding?EricP
|||`* Re: Variable branch length encoding?Stephen Fuld
||| `* Re: Variable branch length encoding?EricP
|||  +- Re: Variable branch length encoding?MitchAlsup
|||  +* Re: Variable branch length encoding?Stephen Fuld
|||  |`* Re: Variable branch length encoding?MitchAlsup
|||  | `* Re: Variable branch length encoding?Stephen Fuld
|||  |  `* Re: Variable branch length encoding?robf...@gmail.com
|||  |   `* Re: Variable branch length encoding?Stephen Fuld
|||  |    `- Re: Variable branch length encoding?Stephen Fuld
|||  `- Re: Variable branch length encoding?Terje Mathisen
||`* Re: Variable branch length encoding?mac
|| `* Re: Variable branch length encoding?Stephen Fuld
||  `* Re: Variable branch length encoding?Terje Mathisen
||   +- Re: Variable branch length encoding?Stephen Fuld
||   `- Re: Variable branch length encoding?John Levine
|+- Re: Variable branch length encoding?MitchAlsup
|`* Re: Variable branch length encoding?MitchAlsup
| `* Re: Variable branch length encoding?BGB
|  `* Re: Variable branch length encoding?MitchAlsup
|   `- Re: Variable branch length encoding?BGB
+* Re: Variable branch length encoding?MitchAlsup
|+* Re: Variable branch length encoding?Terje Mathisen
||`* Re: Variable branch length encoding?MitchAlsup
|| `- Re: Variable branch length encoding?Terje Mathisen
|`- Re: Variable branch length encoding?Paul A. Clayton
+* Re: Variable branch length encoding?Agner Fog
|`* Re: Variable branch length encoding?Thomas Koenig
| `* Re: Variable branch length encoding?Quadibloc
|  `* Re: Variable branch length encoding?Thomas Koenig
|   `* Re: Variable branch length encoding?Quadibloc
|    `* Re: Variable branch length encoding?John Levine
|     `* Re: Variable branch length encoding?MitchAlsup
|      +- Re: Variable branch length encoding?robf...@gmail.com
|      `* Re: Variable branch length encoding?Quadibloc
|       `* Re: Variable branch length encoding?John Levine
|        `* Re: Variable branch length encoding?MitchAlsup
|         `* Re: addressing hacks, Variable branch length encoding?John Levine
|          `* Re: addressing hacks, Variable branch length encoding?MitchAlsup
|           `- Re: addressing hacks, Variable branch length encoding?John Levine
`* Re: Variable branch length encoding?Timothy McCaffrey
 `- Re: Variable branch length encoding?MitchAlsup

Pages:12
Re: Variable branch length encoding?

<cea8e24a-4642-4c1d-aa87-2dd5f6e8b7c5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31018&group=comp.arch#31018

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:4a5c:b0:56f:fe44:f257 with SMTP id ph28-20020a0562144a5c00b0056ffe44f257mr819251qvb.1.1677877287619;
Fri, 03 Mar 2023 13:01:27 -0800 (PST)
X-Received: by 2002:a05:6870:b397:b0:16d:f67f:8258 with SMTP id
w23-20020a056870b39700b0016df67f8258mr3572485oap.4.1677877287466; Fri, 03 Mar
2023 13:01:27 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 3 Mar 2023 13:01:27 -0800 (PST)
In-Reply-To: <tttef2$muvs$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:9c1:d7ee:4db0:7f8;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:9c1:d7ee:4db0:7f8
References: <ttn1gq$3taue$1@dont-email.me> <lKKLL.884821$gGD7.549447@fx11.iad>
<5c89b9b6-b1eb-4100-97ce-ed21d9e6ef06n@googlegroups.com> <tttef2$muvs$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cea8e24a-4642-4c1d-aa87-2dd5f6e8b7c5n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 03 Mar 2023 21:01:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 7131
 by: MitchAlsup - Fri, 3 Mar 2023 21:01 UTC

On Friday, March 3, 2023 at 12:32:06 PM UTC-6, BGB wrote:
> On 3/1/2023 12:44 PM, MitchAlsup wrote:
> > On Wednesday, March 1, 2023 at 10:06:45 AM UTC-6, EricP wrote:
> >> Terje Mathisen wrote:
> >>> Would it be possible or just a bad idea to allow some form of
> >>> variable/fp encoding of branch offsets?
> >>>
> >>> I.e. all small (byte) offsets would be encoded directly, but for longer
> >>> ones you could require the target to be word/dword/qword aligned, and
> >>> therefore allow a much greater range.
> >>>
> >>> It would probably only be useful for inter-module calls/branches...
> >>>
> >>> The main problem is probably that the target address adder is already in
> >>> the critical path, so you can't just add a little shifter there as well.
> >>>
> >>> (Even though LEA r1,[r2+8*r3+0x12345678] is already doing some of this,
> >>> right?)
> >>>
> >>> Terje
> >> As with any variable length instruction, extracting its size
> >> in the parse or decode stage is critical for concurrent decode.
> >> So ideally this offset *won't* be an "fp-like" data item with an
> >> "exponent" field appended to the opcode, but the instruction size
> >> in words is in the first byte and the internal instruction format
> >> is sorted out by decode.
> >>
> >> RIP-relative offsets are often relative to the incremented RIP
> >> and include the variable instruction's length. The alignment
> >> is for both the 'from' and 'to' addresses and aligning just the
> >> destination to 32 or 64 bits won't allow encoding a larger range.
> >>
> >> The issue I had is when instructions are not byte aligned,
> >> in my case 16-bit words. For branches the immediate field is a
> >> relative _word_ count to get one extra bit of offset range.
> >> But what to do when the immediate field is a 64-bit value:
> >> should that still be a word offset count,
> >> or should it switch to being a byte offset count?
> > <
> > Item 1
> >>
> >> For LD and ST the immediate offset is always a byte offset,
> >> even if it is RIP-relative addressing.
> >>
> >> In my naming convention, Branch is to relative offset,
> >> Jump is to an absolute address.
> >>
> >> I have a "BR reg" with the offset in a register,
> >> intended for use in position-independent SWITCH statements.
> >> A scaled-indexed LD of the offset onto a register, then BR reg.
> >> But should that register offset be a byte count or a word count?
> >> Or should I have two "BR reg" instructions, one for each?
> > <
> > I agree that Branches should be to displacements (IP = IP+DISP)
> > I agree that JUMPs should be to absolute locations (IP = value)
> > <
> > The timing in the pipeline where reg becomes available is in conflict
> > with the time when the next fetch address is needed. Reading and
> > forwarding take significantly longer than IP+DISP calculation. So,
> > this typically adds 1 cycle of delay to BR reg forms.
> > <
> > Item 1::
> > <
> > My BR and CALL instructions have a 2^28-bit range from 26-bit
> > displacement.
> > But when I switch to the forms with constants, I switch to
> > absolute addressing.
> My BRA and BSR instructions are 20 bits (relative).
> There are also absolute-48 bit versions (64-bit encoding).
>
> Technically, there are also relative 33 bit branches (also a 64-bit
> encoding), but these will be skipped by the branch predictor (and thus
> slower than either the Disp20 or Abs48 encodings). These will need to
> always take the "slow path" (via the AGU and explicit branch mechanism).
>
> In my case, branch displacements are always in terms of 16 bit units.
> Abs48 gives a byte address, but currently the LSB is effectively MBZ
> (and the instruction stream has a mandatory 16-bit alignment).
>
>
> In my case:
> BRA disp
> Is handled by the branch predictor (in ID1), and has 2 cycle of latency.
<
I scan ahead looking for branches as instructions fill the inst-buffer.
This gives me time to fetch the targets of the branches often before
the branch is decoded, leading to zero-delay in many cases (BR at end
of basic block), but averaging 1.03-cycles over all branches. Thus,
a delay slot does not buy enough to enter consideration.
>
> Avoiding the latency cycle would require handling branch prediction
> during the IF stage.
>
> Most conditional branches depend on whether or not the predictor
> predicts them, etc. Branches will be skipped by the branch predictor if
> they cross a 16 MB boundary (mostly because an adder and carry
> propagation across 24 bits is faster than 48 bits).
<
Predicate instructions are not predicted in my ISA.
LOOP instructions are not predicted ...
BR and CALL and RET and EXIT are not predicted.
only real conditional branches that stand to gain something are predicted.
<snip>
>
> All other branches will take the slower path, having their address
> calculated by the AGU, and then dispatched via the EX1 and EX2 stages
> (taking around 8 clock cycles). The branch is signaled in EX1, but the
> branch mechanism doesn't really start to take action until EX2, mostly
> for timing/latency reasons. The mechanism effectively invalidates
> anything currently in the pipeline following the branch, then signals
> the L1 I$ to start fetching from a new location (crossing back through
> the branch-predictor and then to the L1 I-cache).
<
This sounds like a source of cycles that end up doing noting positive to the
application running.....
>
> ...

Re: Variable branch length encoding?

<1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31020&group=comp.arch#31020

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: acol...@efunct.com (mac)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Fri, 3 Mar 2023 21:27:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>
References: <ttn1gq$3taue$1@dont-email.me>
<lKKLL.884821$gGD7.549447@fx11.iad>
<tto37q$pil$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Mar 2023 21:27:08 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="10c4c43c9f85a454f486e03f0faabb70";
logging-data="785311"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PgJ9BpY8y0EtECJ9XlYBS"
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:P7WmSDqRUITSCdTugTPUnUJltkU=
sha1:aaUuFdmWTwiIA2FjW/2viJqLiQU=
 by: mac - Fri, 3 Mar 2023 21:27 UTC

> I, perhaps mistakenly, interpreted Terje's suggestion differently. I
> don't think he was suggesting variable length instructions, but an
> orthogonal idea. Let's take an example. Suppose you have 10 bits
> available for a branch offset. If the high order bit is zero, the low
> order nine bits give a byte address. But if the high order bit is one,
> you get the address by appending say 3 zero bits to the low order 9
> bits, giving a possible displacement of 12 bits, but restricted to an 8
> byte aligned address.

So... floating point branches?

Re: Variable branch length encoding?

<tttpb5$1lldm$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31021&group=comp.arch#31021

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-1894-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Fri, 3 Mar 2023 21:37:41 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tttpb5$1lldm$1@newsreader4.netcologne.de>
References: <ttn1gq$3taue$1@dont-email.me>
<71ad5eec-2d02-4dee-84b3-e489924233den@googlegroups.com>
<tts4mu$1kj6p$1@newsreader4.netcologne.de>
<c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Mar 2023 21:37:41 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-1894-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:1894:0:7285:c2ff:fe6c:992d";
logging-data="1758646"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 3 Mar 2023 21:37 UTC

Quadibloc <jsavard@ecn.ab.ca> schrieb:
> On Thursday, March 2, 2023 at 11:39:30 PM UTC-7, Thomas Koenig wrote:
>> Agner Fog <ag...@dtu.dk> schrieb:
>> > Terje wrote:
>> >>The main problem is probably that the target address adder is already in
>> >>the critical path, so you can't just add a little shifter there as well.
>> >
>> > It is not in a critical path if you have branch prediction, and the target address
>> > is needed only at the end of a long pipeline.
>> >
>> > The main problem is that you don't know if a target address in a different module
>> > is aligned by a higher power of 2. A misalignment error will only be detected at
>> > the link stage.
>> That can be addressed in the ABI prescribing the alignment of functions
>> in general.
>>
>> It would also be possible to prescribe different alignment for internal
>> and external functions, to save space. But that would have to adddress
>> the question of call via function pointers (e.g. a vtab). And
>> if the compiler does devirtualization... that can get messy.
>
> Of course, in the typical case which I've seen actually existing in the
> wild, this issue simply does not arise.

What does "in the wild" actually mean?

> There is the short form of branch, which is 16 bits long, and contains
> an 8-bit relative offset. This is a multiple of 16 bits, since instructions
> are aligned on 16 bit boundaries, as it's important not to waste bits
> in such a short address.

For architectures which have that, yes. For RISC architectures,
usually instructions are situated on mutliples of four bytes.
But they don't usually have eight-bit offsets, either, which would
make little sense in a 32-bit instruction format.

> There is the long form of branch, which is 32 bits long. There is a
> 16-bit address field in the instruction. This is in bytes; the last bit is
> therefore wasted, this is for consistency with all other memory
> reference instructions, where the address field is also in bytes.

I'm not sure what you which architecture you are referring to.

> Obviously, all jumps to external addresses must be in the long form.

> Attempts to... basically recompile programs in the link stage... are
> a bad idea, I would think.

Have you heard of LTO?

> Of course, some new advanced architecture
> might do things differently from traditional ones.

Old-style RISC is pretty traditional, I would think.

Re: Variable branch length encoding?

<ttu25i$ou8b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31023&group=comp.arch#31023

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Fri, 3 Mar 2023 18:08:16 -0600
Organization: A noiseless patient Spider
Lines: 202
Message-ID: <ttu25i$ou8b$1@dont-email.me>
References: <ttn1gq$3taue$1@dont-email.me> <lKKLL.884821$gGD7.549447@fx11.iad>
<5c89b9b6-b1eb-4100-97ce-ed21d9e6ef06n@googlegroups.com>
<tttef2$muvs$1@dont-email.me>
<cea8e24a-4642-4c1d-aa87-2dd5f6e8b7c5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Mar 2023 00:08:18 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="c439222de89292a942171e21fe7c25af";
logging-data="817419"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EE+TAFuoglS1U36dNq27n"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:BXN52yld2rjOJOtEk/gdNfqEoqM=
In-Reply-To: <cea8e24a-4642-4c1d-aa87-2dd5f6e8b7c5n@googlegroups.com>
Content-Language: en-US
 by: BGB - Sat, 4 Mar 2023 00:08 UTC

On 3/3/2023 3:01 PM, MitchAlsup wrote:
> On Friday, March 3, 2023 at 12:32:06 PM UTC-6, BGB wrote:
>> On 3/1/2023 12:44 PM, MitchAlsup wrote:
>>> On Wednesday, March 1, 2023 at 10:06:45 AM UTC-6, EricP wrote:
>>>> Terje Mathisen wrote:
>>>>> Would it be possible or just a bad idea to allow some form of
>>>>> variable/fp encoding of branch offsets?
>>>>>
>>>>> I.e. all small (byte) offsets would be encoded directly, but for longer
>>>>> ones you could require the target to be word/dword/qword aligned, and
>>>>> therefore allow a much greater range.
>>>>>
>>>>> It would probably only be useful for inter-module calls/branches...
>>>>>
>>>>> The main problem is probably that the target address adder is already in
>>>>> the critical path, so you can't just add a little shifter there as well.
>>>>>
>>>>> (Even though LEA r1,[r2+8*r3+0x12345678] is already doing some of this,
>>>>> right?)
>>>>>
>>>>> Terje
>>>> As with any variable length instruction, extracting its size
>>>> in the parse or decode stage is critical for concurrent decode.
>>>> So ideally this offset *won't* be an "fp-like" data item with an
>>>> "exponent" field appended to the opcode, but the instruction size
>>>> in words is in the first byte and the internal instruction format
>>>> is sorted out by decode.
>>>>
>>>> RIP-relative offsets are often relative to the incremented RIP
>>>> and include the variable instruction's length. The alignment
>>>> is for both the 'from' and 'to' addresses and aligning just the
>>>> destination to 32 or 64 bits won't allow encoding a larger range.
>>>>
>>>> The issue I had is when instructions are not byte aligned,
>>>> in my case 16-bit words. For branches the immediate field is a
>>>> relative _word_ count to get one extra bit of offset range.
>>>> But what to do when the immediate field is a 64-bit value:
>>>> should that still be a word offset count,
>>>> or should it switch to being a byte offset count?
>>> <
>>> Item 1
>>>>
>>>> For LD and ST the immediate offset is always a byte offset,
>>>> even if it is RIP-relative addressing.
>>>>
>>>> In my naming convention, Branch is to relative offset,
>>>> Jump is to an absolute address.
>>>>
>>>> I have a "BR reg" with the offset in a register,
>>>> intended for use in position-independent SWITCH statements.
>>>> A scaled-indexed LD of the offset onto a register, then BR reg.
>>>> But should that register offset be a byte count or a word count?
>>>> Or should I have two "BR reg" instructions, one for each?
>>> <
>>> I agree that Branches should be to displacements (IP = IP+DISP)
>>> I agree that JUMPs should be to absolute locations (IP = value)
>>> <
>>> The timing in the pipeline where reg becomes available is in conflict
>>> with the time when the next fetch address is needed. Reading and
>>> forwarding take significantly longer than IP+DISP calculation. So,
>>> this typically adds 1 cycle of delay to BR reg forms.
>>> <
>>> Item 1::
>>> <
>>> My BR and CALL instructions have a 2^28-bit range from 26-bit
>>> displacement.
>>> But when I switch to the forms with constants, I switch to
>>> absolute addressing.
>> My BRA and BSR instructions are 20 bits (relative).
>> There are also absolute-48 bit versions (64-bit encoding).
>>
>> Technically, there are also relative 33 bit branches (also a 64-bit
>> encoding), but these will be skipped by the branch predictor (and thus
>> slower than either the Disp20 or Abs48 encodings). These will need to
>> always take the "slow path" (via the AGU and explicit branch mechanism).
>>
>> In my case, branch displacements are always in terms of 16 bit units.
>> Abs48 gives a byte address, but currently the LSB is effectively MBZ
>> (and the instruction stream has a mandatory 16-bit alignment).
>>
>>
>> In my case:
>> BRA disp
>> Is handled by the branch predictor (in ID1), and has 2 cycle of latency.
> <
> I scan ahead looking for branches as instructions fill the inst-buffer.
> This gives me time to fetch the targets of the branches often before
> the branch is decoded, leading to zero-delay in many cases (BR at end
> of basic block), but averaging 1.03-cycles over all branches. Thus,
> a delay slot does not buy enough to enter consideration.

There are no delay-slot instructions.

But, there is a "dead cycle" following every branch where a delay slot
could have existed, and if there was not a mechanism to flush this
location, a delay-slot would magically appear.

Some amount of the "boot time sanity checks" were specifically checking
to make sure delay-slot like effects were not happening. Another
long-standing bug itself turned out to be related to a related effect
(namely, flushed instructions were incorrectly generating interlock
stalls and fouling up the branch mechanism).

Though, a few of the ancestor/inspiration ISAs, namely SH-4 and TMS320,
did have branch delay slots.

>>
>> Avoiding the latency cycle would require handling branch prediction
>> during the IF stage.
>>
>> Most conditional branches depend on whether or not the predictor
>> predicts them, etc. Branches will be skipped by the branch predictor if
>> they cross a 16 MB boundary (mostly because an adder and carry
>> propagation across 24 bits is faster than 48 bits).
> <
> Predicate instructions are not predicted in my ISA.
> LOOP instructions are not predicted ...
> BR and CALL and RET and EXIT are not predicted.
> only real conditional branches that stand to gain something are predicted.
> <snip>

The branch predictor is basically functioning as a general purpose
"early branch handler", so deals with both conditional and unconditional
branches (treating unconditional branches as "assume always taken").

There are limits to what it can handle though.

If it is an unknown type of branch or if it crosses a 16MB boundary or
similar, it throws up its hands and lets the slow path deal with it. The
slow path also takes over whenever the branch predictor also guesses a
branch wrong.

Effectively, the address output of the branch predictor looks sort of like:
Addr[47:24] = PC[47:24]
Addr[23: 1] = PC[23: 1] + Disp
Addr[ 0] = 0

Where it uses the carry output from the adder to determine whether or
not to use its predicted address (if it can't be handled with a
bit-slice, the branch predictor opts-out).

>>
>> All other branches will take the slower path, having their address
>> calculated by the AGU, and then dispatched via the EX1 and EX2 stages
>> (taking around 8 clock cycles). The branch is signaled in EX1, but the
>> branch mechanism doesn't really start to take action until EX2, mostly
>> for timing/latency reasons. The mechanism effectively invalidates
>> anything currently in the pipeline following the branch, then signals
>> the L1 I$ to start fetching from a new location (crossing back through
>> the branch-predictor and then to the L1 I-cache).
> <
> This sounds like a source of cycles that end up doing noting positive to the
> application running.....

Ideally, one wants to avoid slow-path branches.

So, some examples:
Fast Path (~ 2c):
BRA Disp8 //16-bit
BT Disp8 //16-bit
BF Disp8 //16-bit
BRA Disp20
BSR Disp20
BT Disp20
BF Disp20
Bxx Rn, Disp8 {BEQ/BNE/BLT/BGE/BLE/BGT}
BRA Abs48 //64-bit
BSR Abs48 //64-bit
RTS
JMP R1
Slow Path (~ 8c):
JMP Rn // Rn => PC
JSR Rn // PC => LR; Rn => PC
BRAF Rn // (PC, Rn) => PC
BSRF Rn // PC => LR; (PC, Rn) => PC
BRA Disp33 //64-bit
BSR Disp33 //64-bit

The fast-path cases represent the vast majority of branch instructions.

Main reason Abs48 is in the fast path is mostly because handling it does
not require a carry-chain (whereas Disp33 would require carry across the
full 48 bits; so is left for the slow path).

Generally, the AGU also deals with Addr48+Disp33 cases (though the
Disp33 effectively expands to 36-bits due to the 1/2/4/8 scale).


Click here to read the complete article
Re: Variable branch length encoding?

<13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31024&group=comp.arch#31024

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:43d5:0:b0:73b:a221:2c8e with SMTP id q204-20020a3743d5000000b0073ba2212c8emr1049851qka.4.1677897017447;
Fri, 03 Mar 2023 18:30:17 -0800 (PST)
X-Received: by 2002:a05:6808:987:b0:383:db64:65 with SMTP id
a7-20020a056808098700b00383db640065mr3781625oic.4.1677897017201; Fri, 03 Mar
2023 18:30:17 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 3 Mar 2023 18:30:16 -0800 (PST)
In-Reply-To: <tttpb5$1lldm$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=162.157.97.93; posting-account=1nOeKQkAAABD2jxp4Pzmx9Hx5g9miO8y
NNTP-Posting-Host: 162.157.97.93
References: <ttn1gq$3taue$1@dont-email.me> <71ad5eec-2d02-4dee-84b3-e489924233den@googlegroups.com>
<tts4mu$1kj6p$1@newsreader4.netcologne.de> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com>
<tttpb5$1lldm$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: jsav...@ecn.ab.ca (Quadibloc)
Injection-Date: Sat, 04 Mar 2023 02:30:17 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1922
 by: Quadibloc - Sat, 4 Mar 2023 02:30 UTC

On Friday, March 3, 2023 at 2:37:44 PM UTC-7, Thomas Koenig wrote:
> Quadibloc <jsa...@ecn.ab.ca> schrieb:

> > There is the long form of branch, which is 32 bits long. There is a
> > 16-bit address field in the instruction. This is in bytes; the last bit is
> > therefore wasted, this is for consistency with all other memory
> > reference instructions, where the address field is also in bytes.
>
> I'm not sure what you which architecture you are referring to.

One example of this is the TI 9900 chip.

I think the original PDP-11 is another example.

John Savard

Re: Variable branch length encoding?

<ttuc03$466$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31025&group=comp.arch#31025

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.cmpublishers.com!adore2!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sat, 4 Mar 2023 02:56:03 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <ttuc03$466$1@gal.iecc.com>
References: <ttn1gq$3taue$1@dont-email.me> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com> <tttpb5$1lldm$1@newsreader4.netcologne.de> <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
Injection-Date: Sat, 4 Mar 2023 02:56:03 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="4294"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <ttn1gq$3taue$1@dont-email.me> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com> <tttpb5$1lldm$1@newsreader4.netcologne.de> <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 4 Mar 2023 02:56 UTC

It appears that Quadibloc <jsavard@ecn.ab.ca> said:
>On Friday, March 3, 2023 at 2:37:44 PM UTC-7, Thomas Koenig wrote:
>> Quadibloc <jsa...@ecn.ab.ca> schrieb:
>
>> > There is the long form of branch, which is 32 bits long. There is a
>> > 16-bit address field in the instruction. This is in bytes; the last bit is
>> > therefore wasted, this is for consistency with all other memory
>> > reference instructions, where the address field is also in bytes.
>>
>> I'm not sure what you which architecture you are referring to.

On S/360, branch addreesses are computed the same way as any other
address, but instructions are halfword (16 bit) aligned so the low bit
in the displacement is wasted. S/390 finally added relative branches
where the operand is a 16 or 32 bit value that is shifted one bit to
the left, so there's no wasted address bit. Since it had 32 bit
addressing, the long relative branch could branch anywhere. zSeries
expanded addresses to 64 bits but the relative branch instructions
stayed the same.

The PDP-11 had a full set of conditional and unconditional branches
which contained an 8-bit signed offset, shifted one bit since
instructions were 16-bit word aligned. It also had JMP and JSR
instructions that had the regular address modes including absolute
addresses or 16 bit index offset.

The Unix PDP-11 assemblers had conditional jump pseudo instructions
that would turn into a branch if the target was close enough, a
reverse branch over a jump otherwise. There were a few papers on how
to generate the code; the usual one was to start by assuming all the
jumps were in the long form, then loop looking for one it could
shorten, adjust the instruction addressess, repeat until done.

An obvious improvement is to chain branches, look for a jump to the
same address that is close enough for a short branch to that jump.
Unforunately, that turned out to be NP-complete.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Variable branch length encoding?

<6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31026&group=comp.arch#31026

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:b09:b0:56f:6b7:3a7b with SMTP id u9-20020a0562140b0900b0056f06b73a7bmr964311qvj.7.1677903849801;
Fri, 03 Mar 2023 20:24:09 -0800 (PST)
X-Received: by 2002:a05:6830:24bc:b0:693:cf8e:a31e with SMTP id
v28-20020a05683024bc00b00693cf8ea31emr1143288ots.6.1677903849534; Fri, 03 Mar
2023 20:24:09 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 3 Mar 2023 20:24:09 -0800 (PST)
In-Reply-To: <ttuc03$466$1@gal.iecc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:34c9:6b26:c840:aeed;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:34c9:6b26:c840:aeed
References: <ttn1gq$3taue$1@dont-email.me> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com>
<tttpb5$1lldm$1@newsreader4.netcologne.de> <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
<ttuc03$466$1@gal.iecc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 04 Mar 2023 04:24:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4134
 by: MitchAlsup - Sat, 4 Mar 2023 04:24 UTC

On Friday, March 3, 2023 at 8:56:07 PM UTC-6, John Levine wrote:
> It appears that Quadibloc <jsa...@ecn.ab.ca> said:
> >On Friday, March 3, 2023 at 2:37:44 PM UTC-7, Thomas Koenig wrote:
> >> Quadibloc <jsa...@ecn.ab.ca> schrieb:
> >
> >> > There is the long form of branch, which is 32 bits long. There is a
> >> > 16-bit address field in the instruction. This is in bytes; the last bit is
> >> > therefore wasted, this is for consistency with all other memory
> >> > reference instructions, where the address field is also in bytes.
> >>
> >> I'm not sure what you which architecture you are referring to.
> On S/360, branch addreesses are computed the same way as any other
> address, but instructions are halfword (16 bit) aligned so the low bit
> in the displacement is wasted. S/390 finally added relative branches
> where the operand is a 16 or 32 bit value that is shifted one bit to
> the left, so there's no wasted address bit. Since it had 32 bit
> addressing, the long relative branch could branch anywhere. zSeries
> expanded addresses to 64 bits but the relative branch instructions
> stayed the same.
>
> The PDP-11 had a full set of conditional and unconditional branches
> which contained an 8-bit signed offset, shifted one bit since
> instructions were 16-bit word aligned. It also had JMP and JSR
> instructions that had the regular address modes including absolute
> addresses or 16 bit index offset.
>
> The Unix PDP-11 assemblers had conditional jump pseudo instructions
> that would turn into a branch if the target was close enough, a
> reverse branch over a jump otherwise. There were a few papers on how
> to generate the code; the usual one was to start by assuming all the
> jumps were in the long form, then loop looking for one it could
> shorten, adjust the instruction addressess, repeat until done.
<
In effect, the Mc88K link process worked just like this--assume the
branch displacement was not big enough, and have the linker shrink
the code when it was long enough. Shrinking means that already resolved
branch targets would not change when a shrink occurred.
>
> An obvious improvement is to chain branches, look for a jump to the
> same address that is close enough for a short branch to that jump.
> Unforunately, that turned out to be NP-complete.
<
And it is so rare to find a subroutine with more than 65K instructions
in it that the complexity is unwarranted.
>
>
>
> --
> Regards,
> John Levine, jo...@taugh.com, Primary Perpetrator of "The Internet for Dummies",
> Please consider the environment before reading this e-mail. https://jl.ly

Re: Variable branch length encoding?

<06121142-faa0-4541-9f9f-cddaca762153n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31027&group=comp.arch#31027

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:18d2:b0:56e:a4a7:b3a with SMTP id cy18-20020a05621418d200b0056ea4a70b3amr1072941qvb.3.1677907394701;
Fri, 03 Mar 2023 21:23:14 -0800 (PST)
X-Received: by 2002:aca:1a09:0:b0:384:34c4:db1d with SMTP id
a9-20020aca1a09000000b0038434c4db1dmr1274842oia.1.1677907394508; Fri, 03 Mar
2023 21:23:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 3 Mar 2023 21:23:14 -0800 (PST)
In-Reply-To: <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.251.79.92; posting-account=QId4bgoAAABV4s50talpu-qMcPp519Eb
NNTP-Posting-Host: 99.251.79.92
References: <ttn1gq$3taue$1@dont-email.me> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com>
<tttpb5$1lldm$1@newsreader4.netcologne.de> <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
<ttuc03$466$1@gal.iecc.com> <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <06121142-faa0-4541-9f9f-cddaca762153n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: robfi...@gmail.com (robf...@gmail.com)
Injection-Date: Sat, 04 Mar 2023 05:23:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3038
 by: robf...@gmail.com - Sat, 4 Mar 2023 05:23 UTC

>And it is so rare to find a subroutine with more than 65K instructions
>in it that the complexity is unwarranted.

The PC increment does not need to increment many more than 16 of the LSBs.
PC lowest 20 bits could be incremented / adjusted by branch instructions while
the remaining upper bits remain unchanged. 65C816 only increments across the
16 LSBs. It is tempting to just load 16 bits of the branch target field directly into
the low order 16 bits of the PC, ignoring the upper bits. It would save an adder.
It could be done if routines were always packed entirely in a 64kB space.
Positioning of code would need to be limited to 64kB blocks for PIC. Thor2023
just happens to be using 64kB memory pages.

Thor2023 is using a branch target buffer accessed in the IFETCH stage to do branch
predictions. Next a branch predictor in the decode stage can override the target
buffer prediction. Finally, a perceptron predictor may be used from the execute stage.

Radically altered branches for Thor2023. Decided to use fused compare-and-branch
instead of a separate compare preceding the branch. Too many bits were being
wasted on the branch displacement, when it was possible instead to include a
second register spec. The displacement bits are reduced to 16 from 24 and a six
bit register spec added. In addition to RR branches, RI branches are also supported
now. There was enough room for an eight-bit immediate in the branch instruction;
larger immediates can also be compared using postfix immediate values.

Unconditional branches have had their range extended by four address bits to
128MB (28-bits).

Memory indirect branching using tables is now in the ISA.

Re: Variable branch length encoding?

<ttum9d$tel3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31028&group=comp.arch#31028

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: sfu...@alumni.cmu.edu.invalid (Stephen Fuld)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Fri, 3 Mar 2023 21:51:41 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ttum9d$tel3$1@dont-email.me>
References: <ttn1gq$3taue$1@dont-email.me> <lKKLL.884821$gGD7.549447@fx11.iad>
<tto37q$pil$1@dont-email.me>
<1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Mar 2023 05:51:42 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="c15c0d493a24f338ab7c8333f211407d";
logging-data="965283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TfvjIFDrzywVNzKMimuLlA5450gSQd+A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:mKAWrv2HF82qjfzigt9fHgttVeE=
Content-Language: en-US
In-Reply-To: <1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>
 by: Stephen Fuld - Sat, 4 Mar 2023 05:51 UTC

On 3/3/2023 1:27 PM, mac wrote:
>> I, perhaps mistakenly, interpreted Terje's suggestion differently. I
>> don't think he was suggesting variable length instructions, but an
>> orthogonal idea. Let's take an example. Suppose you have 10 bits
>> available for a branch offset. If the high order bit is zero, the low
>> order nine bits give a byte address. But if the high order bit is one,
>> you get the address by appending say 3 zero bits to the low order 9
>> bits, giving a possible displacement of 12 bits, but restricted to an 8
>> byte aligned address.
>
> So... floating point branches?

Only by a very strained definition of "floating point", as there are no
non-integer branch displacements, and what you might call the "exponent"
can only have two values, and they are not "consecutive" powers of two,
and, of course, no signed values. But other than those . . . :-)

--
- Stephen Fuld
(e-mail address disguised to prevent spam)

Re: Variable branch length encoding?

<ttv3g2$uklr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31029&group=comp.arch#31029

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sat, 4 Mar 2023 10:37:05 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <ttv3g2$uklr$1@dont-email.me>
References: <ttn1gq$3taue$1@dont-email.me> <lKKLL.884821$gGD7.549447@fx11.iad>
<tto37q$pil$1@dont-email.me>
<1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>
<ttum9d$tel3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Mar 2023 09:37:06 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="fab4767abfa88b94d76f5cc979c7faf4";
logging-data="1004219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9a4Of85Ii2ENpIKcNnUcupMFesBNH2U2TmtpsmNAaPQ=="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.15
Cancel-Lock: sha1:zgVAqS0XlAuyJjnlehMICuzqHGU=
In-Reply-To: <ttum9d$tel3$1@dont-email.me>
 by: Terje Mathisen - Sat, 4 Mar 2023 09:37 UTC

Stephen Fuld wrote:
> On 3/3/2023 1:27 PM, mac wrote:
>>> I, perhaps mistakenly, interpreted Terje's suggestion differently.  I
>>> don't think he was suggesting variable length instructions, but an
>>> orthogonal idea.  Let's take an example.   Suppose you have 10 bits
>>> available for a branch offset. If the high order bit is zero, the low
>>> order nine bits give a byte address.  But if the high order bit is one,
>>> you get the address by appending say 3 zero bits to the low order 9
>>> bits, giving a possible displacement of 12 bits, but restricted to an 8
>>> byte aligned address.
>>
>> So... floating point branches?
>
> Only by a very strained definition of "floating point", as there are no
> non-integer branch displacements, and what you might call the "exponent"
> can only have two values, and they are not "consecutive" powers of two,
> and, of course, no signed values.  But other than those  . . .  :-)

Signed is obviously OK, we want to be able to branch in both directions!

Otherwise you are spot on. :-)

My idea was really based on using a different ABI for
exported/public/intermodule targets, so that these would always have to
be generated with the required alignment (probably 8 or 16 bytes as the
most feasible), then getting a similarly extended addressing range for
code that needs to reach them without using a full 64-bit address.

I still don't think it would be a net win anywhere but if you only
expose the ideas that you are sure to be a win, then you won't get any
external opinions, like I'm getting here. :-)

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Variable branch length encoding?

<ttvpdg$10n2d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31030&group=comp.arch#31030

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: sfu...@alumni.cmu.edu.invalid (Stephen Fuld)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sat, 4 Mar 2023 07:51:12 -0800
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <ttvpdg$10n2d$1@dont-email.me>
References: <ttn1gq$3taue$1@dont-email.me> <lKKLL.884821$gGD7.549447@fx11.iad>
<tto37q$pil$1@dont-email.me>
<1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org>
<ttum9d$tel3$1@dont-email.me> <ttv3g2$uklr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Mar 2023 15:51:12 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="7d59b973037e309627c57aefd2fc461a";
logging-data="1072205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KXkeN3Os6izatodRqNXtNUGIvdFJDBNk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:Jh297yUMQrwydA+F5vVUVUMbHWQ=
Content-Language: en-US
In-Reply-To: <ttv3g2$uklr$1@dont-email.me>
 by: Stephen Fuld - Sat, 4 Mar 2023 15:51 UTC

On 3/4/2023 1:37 AM, Terje Mathisen wrote:
> Stephen Fuld wrote:
>> On 3/3/2023 1:27 PM, mac wrote:
>>>> I, perhaps mistakenly, interpreted Terje's suggestion differently.  I
>>>> don't think he was suggesting variable length instructions, but an
>>>> orthogonal idea.  Let's take an example.   Suppose you have 10 bits
>>>> available for a branch offset. If the high order bit is zero, the low
>>>> order nine bits give a byte address.  But if the high order bit is one,
>>>> you get the address by appending say 3 zero bits to the low order 9
>>>> bits, giving a possible displacement of 12 bits, but restricted to an 8
>>>> byte aligned address.
>>>
>>> So... floating point branches?
>>
>> Only by a very strained definition of "floating point", as there are
>> no non-integer branch displacements, and what you might call the
>> "exponent" can only have two values, and they are not "consecutive"
>> powers of two, and, of course, no signed values.  But other than
>> those  . . .  :-)
>
> Signed is obviously OK, we want to be able to branch in both directions!

Of course. Sorry, I got carried away. :-)

>
> Otherwise you are spot on. :-)
>
> My idea was really based on using a different ABI for
> exported/public/intermodule targets, so that these would always have to
> be generated with the required alignment (probably 8 or 16 bytes as the
> most feasible), then getting a similarly extended addressing range for
> code that needs to reach them without using a full 64-bit address.
>
> I still don't think it would be a net win anywhere but if you only
> expose the ideas that you are sure to be a win, then you won't get any
> external opinions, like I'm getting here. :-)

I agree with both of those points. :-)

--
- Stephen Fuld
(e-mail address disguised to prevent spam)

Re: Variable branch length encoding?

<f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31031&group=comp.arch#31031

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:56fc:0:b0:3bf:bd9f:ee5a with SMTP id 28-20020ac856fc000000b003bfbd9fee5amr1547255qtu.8.1677945081294;
Sat, 04 Mar 2023 07:51:21 -0800 (PST)
X-Received: by 2002:a05:6870:98af:b0:176:2b10:5f9f with SMTP id
eg47-20020a05687098af00b001762b105f9fmr1720014oab.7.1677945080613; Sat, 04
Mar 2023 07:51:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 4 Mar 2023 07:51:20 -0800 (PST)
In-Reply-To: <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=162.157.97.93; posting-account=1nOeKQkAAABD2jxp4Pzmx9Hx5g9miO8y
NNTP-Posting-Host: 162.157.97.93
References: <ttn1gq$3taue$1@dont-email.me> <c25a36b6-7a49-4d4a-b39c-3229e76cd423n@googlegroups.com>
<tttpb5$1lldm$1@newsreader4.netcologne.de> <13da4df3-c6d5-489d-bda3-bbf462dc758dn@googlegroups.com>
<ttuc03$466$1@gal.iecc.com> <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: jsav...@ecn.ab.ca (Quadibloc)
Injection-Date: Sat, 04 Mar 2023 15:51:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Quadibloc - Sat, 4 Mar 2023 15:51 UTC

On Friday, March 3, 2023 at 9:24:11 PM UTC-7, MitchAlsup wrote:
> On Friday, March 3, 2023 at 8:56:07 PM UTC-6, John Levine wrote:

> > An obvious improvement is to chain branches, look for a jump to the
> > same address that is close enough for a short branch to that jump.
> > Unforunately, that turned out to be NP-complete.

> And it is so rare to find a subroutine with more than 65K instructions
> in it that the complexity is unwarranted.

Um, this would apply to the case of subroutines with more than 256
instructions.

It would be _very_ rare to find a routine with more than 65,536 instructions
(each at least 16 bits in size) in it on a PDP-11 simply because its address
space (except for high-end models with special memory extension hardware)
was 65,536 bytes.

John Savard

Re: Variable branch length encoding?

<ttvq5g$1tr7$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31032&group=comp.arch#31032

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sat, 4 Mar 2023 16:04:00 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <ttvq5g$1tr7$1@gal.iecc.com>
References: <ttn1gq$3taue$1@dont-email.me> <1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org> <ttum9d$tel3$1@dont-email.me> <ttv3g2$uklr$1@dont-email.me>
Injection-Date: Sat, 4 Mar 2023 16:04:00 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="63335"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <ttn1gq$3taue$1@dont-email.me> <1716928683.699571269.702429.acolvin-efunct.com@news.eternal-september.org> <ttum9d$tel3$1@dont-email.me> <ttv3g2$uklr$1@dont-email.me>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 4 Mar 2023 16:04 UTC

According to Terje Mathisen <terje.mathisen@tmsw.no>:
>My idea was really based on using a different ABI for
>exported/public/intermodule targets, so that these would always have to
>be generated with the required alignment (probably 8 or 16 bytes as the
>most feasible), then getting a similarly extended addressing range for
>code that needs to reach them without using a full 64-bit address.

I've seen ABIs where public routines have to be word aligned and there
is stuff before the routine to help with debugging, e.g., routine name
and argument signature.

I agree that it's not worth an instruction format. In normal code,
external calls should be less common than internal ones, so it's not a
big deal if their encoding is bigger.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Variable branch length encoding?

<ttvqc2$1tr7$2@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31033&group=comp.arch#31033

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sat, 4 Mar 2023 16:07:30 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <ttvqc2$1tr7$2@gal.iecc.com>
References: <ttn1gq$3taue$1@dont-email.me> <ttuc03$466$1@gal.iecc.com> <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>
Injection-Date: Sat, 4 Mar 2023 16:07:30 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="63335"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <ttn1gq$3taue$1@dont-email.me> <ttuc03$466$1@gal.iecc.com> <6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 4 Mar 2023 16:07 UTC

According to Quadibloc <jsavard@ecn.ab.ca>:
>On Friday, March 3, 2023 at 9:24:11 PM UTC-7, MitchAlsup wrote:
>> On Friday, March 3, 2023 at 8:56:07 PM UTC-6, John Levine wrote:
>
>> > An obvious improvement is to chain branches, look for a jump to the
>> > same address that is close enough for a short branch to that jump.
>> > Unforunately, that turned out to be NP-complete.
>
>> And it is so rare to find a subroutine with more than 65K instructions
>> in it that the complexity is unwarranted.
>
>Um, this would apply to the case of subroutines with more than 256
>instructions.

Right.

>It would be _very_ rare to find a routine with more than 65,536 instructions
>(each at least 16 bits in size) in it on a PDP-11 simply because its address
>space (except for high-end models with special memory extension hardware)
>was 65,536 bytes.

Even on the high end models, each process only had 16 bit addresses.
The operating system could use all that memory to map multiple
processes but there was no reasonable way to put more than 64K code
and 64K data in one process.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Variable branch length encoding?

<de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31034&group=comp.arch#31034

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:1703:b0:3bf:c180:584b with SMTP id h3-20020a05622a170300b003bfc180584bmr3215143qtk.1.1677952758253;
Sat, 04 Mar 2023 09:59:18 -0800 (PST)
X-Received: by 2002:a4a:88a2:0:b0:525:2408:bbfc with SMTP id
j31-20020a4a88a2000000b005252408bbfcmr2379296ooa.1.1677952757987; Sat, 04 Mar
2023 09:59:17 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 4 Mar 2023 09:59:17 -0800 (PST)
In-Reply-To: <ttvqc2$1tr7$2@gal.iecc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:2db2:b61e:2e7c:357e;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:2db2:b61e:2e7c:357e
References: <ttn1gq$3taue$1@dont-email.me> <ttuc03$466$1@gal.iecc.com>
<6d30eb8d-ea19-4cd7-bcb3-d63d383e9b66n@googlegroups.com> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>
<ttvqc2$1tr7$2@gal.iecc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 04 Mar 2023 17:59:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3130
 by: MitchAlsup - Sat, 4 Mar 2023 17:59 UTC

On Saturday, March 4, 2023 at 10:07:34 AM UTC-6, John Levine wrote:
> According to Quadibloc <jsa...@ecn.ab.ca>:
> >On Friday, March 3, 2023 at 9:24:11 PM UTC-7, MitchAlsup wrote:
> >> On Friday, March 3, 2023 at 8:56:07 PM UTC-6, John Levine wrote:
> >
> >> > An obvious improvement is to chain branches, look for a jump to the
> >> > same address that is close enough for a short branch to that jump.
> >> > Unforunately, that turned out to be NP-complete.
> >
> >> And it is so rare to find a subroutine with more than 65K instructions
> >> in it that the complexity is unwarranted.
> >
> >Um, this would apply to the case of subroutines with more than 256
> >instructions.
> Right.
> >It would be _very_ rare to find a routine with more than 65,536 instructions
> >(each at least 16 bits in size) in it on a PDP-11 simply because its address
> >space (except for high-end models with special memory extension hardware)
> >was 65,536 bytes.
> Even on the high end models, each process only had 16 bit addresses.
<
But there was separate code and data spaces of 16-bits each.
<
Also note: the OS in one pair of 16-bit address spaces could access the
code and data in another pair of address spaces using read-from and
write-to instructions (possible after setting up some address space
controls points.)
<
> The operating system could use all that memory to map multiple
> processes but there was no reasonable way to put more than 64K code
> and 64K data in one process.
> --
> Regards,
> John Levine, jo...@taugh.com, Primary Perpetrator of "The Internet for Dummies",
> Please consider the environment before reading this e-mail. https://jl.ly

Re: addressing hacks, Variable branch length encoding?

<tu08kc$7e7$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31035&group=comp.arch#31035

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: addressing hacks, Variable branch length encoding?
Date: Sat, 4 Mar 2023 20:10:52 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <tu08kc$7e7$1@gal.iecc.com>
References: <ttn1gq$3taue$1@dont-email.me> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com> <ttvqc2$1tr7$2@gal.iecc.com> <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com>
Injection-Date: Sat, 4 Mar 2023 20:10:52 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="7623"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <ttn1gq$3taue$1@dont-email.me> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com> <ttvqc2$1tr7$2@gal.iecc.com> <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 4 Mar 2023 20:10 UTC

According to MitchAlsup <MitchAlsup@aol.com>:
>> Even on the high end models, each process only had 16 bit addresses.
><
>But there was separate code and data spaces of 16-bits each.

Yes.

>Also note: the OS in one pair of 16-bit address spaces could access the
>code and data in another pair of address spaces using read-from and
>write-to instructions (possible after setting up some address space
>controls points.)

Yes, but it wasn't that useful. The 11/45 had three modes, kernel,
supervisor, and user, and instructions move to/from previous
instruction/data space which the kernel used to manage the user space.
You couldn't use it from one user process to another.

when I was at Yale, we had some early bitmap terminals. I first did a
hack to map your screen memory into the high half of your process data
space, but it was pretty painful to lose that much address space. Unix
didn't use the supervisor mode so I came up with a hack to put the
screen memory into the supervisor data space, then set the previous
mode in user programs to be supervisor, and it worked. MFPD and MTPD
instructions read and wrote screen memory directly. C didn't generate
those instructions but a little assembler library did the trick and
was plenty fast for the stuff we were doing.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: addressing hacks, Variable branch length encoding?

<095ff090-6d71-4f6b-b294-64e13e28f0b4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31036&group=comp.arch#31036

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:1408:b0:56c:1704:b11c with SMTP id pr8-20020a056214140800b0056c1704b11cmr1476470qvb.7.1677971520958;
Sat, 04 Mar 2023 15:12:00 -0800 (PST)
X-Received: by 2002:a05:6871:6a81:b0:176:207c:1c8d with SMTP id
zf1-20020a0568716a8100b00176207c1c8dmr2031594oab.9.1677971520755; Sat, 04 Mar
2023 15:12:00 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 4 Mar 2023 15:12:00 -0800 (PST)
In-Reply-To: <tu08kc$7e7$1@gal.iecc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:2db2:b61e:2e7c:357e;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:2db2:b61e:2e7c:357e
References: <ttn1gq$3taue$1@dont-email.me> <f648ebee-a81e-4263-83ae-cc98681db150n@googlegroups.com>
<ttvqc2$1tr7$2@gal.iecc.com> <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com>
<tu08kc$7e7$1@gal.iecc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <095ff090-6d71-4f6b-b294-64e13e28f0b4n@googlegroups.com>
Subject: Re: addressing hacks, Variable branch length encoding?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 04 Mar 2023 23:12:00 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3219
 by: MitchAlsup - Sat, 4 Mar 2023 23:12 UTC

On Saturday, March 4, 2023 at 2:10:56 PM UTC-6, John Levine wrote:
> According to MitchAlsup <Mitch...@aol.com>:
> >> Even on the high end models, each process only had 16 bit addresses.
> ><
> >But there was separate code and data spaces of 16-bits each.
> Yes.
> >Also note: the OS in one pair of 16-bit address spaces could access the
> >code and data in another pair of address spaces using read-from and
> >write-to instructions (possible after setting up some address space
> >controls points.)
<
> Yes, but it wasn't that useful. The 11/45 had three modes, kernel,
> supervisor, and user, and instructions move to/from previous
> instruction/data space which the kernel used to manage the user space.
> You couldn't use it from one user process to another.
<
That is why the first sentence of the above paragraph started "the OS in".
Nowhere did I imply that applications could perform those instructions.
>
> when I was at Yale, we had some early bitmap terminals. I first did a
> hack to map your screen memory into the high half of your process data
> space, but it was pretty painful to lose that much address space. Unix
> didn't use the supervisor mode so I came up with a hack to put the
> screen memory into the supervisor data space, then set the previous
> mode in user programs to be supervisor, and it worked. MFPD and MTPD
> instructions read and wrote screen memory directly. C didn't generate
> those instructions but a little assembler library did the trick and
> was plenty fast for the stuff we were doing.
<
Cute, but only works with 1 terminal......
> --
> Regards,
> John Levine, jo...@taugh.com, Primary Perpetrator of "The Internet for Dummies",
> Please consider the environment before reading this e-mail. https://jl.ly

Re: addressing hacks, Variable branch length encoding?

<tu0tvf$26ks$1@gal.iecc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31039&group=comp.arch#31039

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: addressing hacks, Variable branch length encoding?
Date: Sun, 5 Mar 2023 02:15:11 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <tu0tvf$26ks$1@gal.iecc.com>
References: <ttn1gq$3taue$1@dont-email.me> <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com> <tu08kc$7e7$1@gal.iecc.com> <095ff090-6d71-4f6b-b294-64e13e28f0b4n@googlegroups.com>
Injection-Date: Sun, 5 Mar 2023 02:15:11 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="72348"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <ttn1gq$3taue$1@dont-email.me> <de215f91-cd05-474a-9c76-56ac434120bdn@googlegroups.com> <tu08kc$7e7$1@gal.iecc.com> <095ff090-6d71-4f6b-b294-64e13e28f0b4n@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sun, 5 Mar 2023 02:15 UTC

>That is why the first sentence of the above paragraph started "the OS in".
>Nowhere did I imply that applications could perform those instructions.

Well, actually, they could, although in the absence of my hack, they
weren't useful because the previous and current address space were the
same.

>> when I was at Yale, we had some early bitmap terminals. I first did a
>> hack to map your screen memory into the high half of your process data
>> space, but it was pretty painful to lose that much address space. Unix
>> didn't use the supervisor mode so I came up with a hack to put the
>> screen memory into the supervisor data space, then set the previous
>> mode in user programs to be supervisor, and it worked. MFPD and MTPD
>> instructions read and wrote screen memory directly. C didn't generate
>> those instructions but a little assembler library did the trick and
>> was plenty fast for the stuff we were doing.
><
>Cute, but only works with 1 terminal......

No, it worked with all 16 terminals. I added a line to the process
switch code so the supervisor addresses pointed to the right chunk of
screen memory for the current process.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Variable branch length encoding?

<tu26gr$1bmq2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31042&group=comp.arch#31042

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: paaroncl...@gmail.com (Paul A. Clayton)
Newsgroups: comp.arch
Subject: Re: Variable branch length encoding?
Date: Sun, 5 Mar 2023 08:47:06 -0500
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <tu26gr$1bmq2$1@dont-email.me>
References: <ttn1gq$3taue$1@dont-email.me>
<f7d4bf44-d8cb-4359-8d32-dbe06bb247ebn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 5 Mar 2023 13:47:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9445f7801f1d3c29a5ade0618e4dd443";
logging-data="1432386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SYrxTx9AVX6HPnUinDbOdf/fdfeZ1SvU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:IAQWGWbD69AgS40z+mjauWUk9aI=
In-Reply-To: <f7d4bf44-d8cb-4359-8d32-dbe06bb247ebn@googlegroups.com>
 by: Paul A. Clayton - Sun, 5 Mar 2023 13:47 UTC

MitchAlsup wrote:
[snip]
> It is generally OK to place entry-points on cache line boundaries (about 64Byte
> alignments) so you get 8 low order bits (which word instruction machines
> already use the lowest 2-bits.) A gain of 6-bits.
> <
> It is generally not OK to require cache line alignment on labels within a
> subroutine.
> <
> It is generally a good idea that BR and CALL use the same multiplexer
> and address generator. So, mainly my first paragraph above is in conflict
> with the leading sentence of this paragraph.

Using the additional low bits of the more aligned form for most
significant bits (or a segment indicator??) would allow the
addition of intermediate bits to be the same for both instruction
types. The conditional (based on instruction type) masking of
those bits would presumably not add that much delay and the carry
propagation delay (and likely delayed use of the most significant
bits of the result) could cover some time for moving the bits.

(The low bits might also be used as non-address data, perhaps a
permission request? This would seem to eliminate timing issues, at
least if those first bits were a carry chunk [the carry could be
set as zero early], and there would be no difference in the upper
part of the address generator.)

Regardless of the method of providing more aligned targets,
whether the additional complexity and delay are worthwhile would
seem to depend on the benefits from the additional alignment
relative to the costs. I suspect the benefit does not justify the
complexity. (I _think_ XTensa had variable alignment calls, so
there may be some cases where it is worthwhile.)

Re: Variable branch length encoding?

<1a969f26-7970-45a5-bc30-9581a2491459n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31194&group=comp.arch#31194

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6000:1002:b0:2cf:ee42:9c83 with SMTP id a2-20020a056000100200b002cfee429c83mr584437wrx.1.1678889270240;
Wed, 15 Mar 2023 07:07:50 -0700 (PDT)
X-Received: by 2002:a05:6871:460b:b0:177:b541:7aea with SMTP id
nf11-20020a056871460b00b00177b5417aeamr4722241oab.2.1678889269283; Wed, 15
Mar 2023 07:07:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Wed, 15 Mar 2023 07:07:48 -0700 (PDT)
In-Reply-To: <ttn1gq$3taue$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=71.230.96.169; posting-account=ujX_IwoAAACu0_cef9hMHeR8g0ZYDNHh
NNTP-Posting-Host: 71.230.96.169
References: <ttn1gq$3taue$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1a969f26-7970-45a5-bc30-9581a2491459n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: timcaff...@aol.com (Timothy McCaffrey)
Injection-Date: Wed, 15 Mar 2023 14:07:50 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Timothy McCaffrey - Wed, 15 Mar 2023 14:07 UTC

On Wednesday, March 1, 2023 at 3:14:22 AM UTC-5, Terje Mathisen wrote:
> Would it be possible or just a bad idea to allow some form of
> variable/fp encoding of branch offsets?
>
> I.e. all small (byte) offsets would be encoded directly, but for longer
> ones you could require the target to be word/dword/qword aligned, and
> therefore allow a much greater range.
>
> It would probably only be useful for inter-module calls/branches...
>
> The main problem is probably that the target address adder is already in
> the critical path, so you can't just add a little shifter there as well.
>
> (Even though LEA r1,[r2+8*r3+0x12345678] is already doing some of this,
> right?)
>
> Terje
>

The 68000 had a 16 bit conditional branch, 8 bits of which were a signed offset for the branch target.
Annoyingly, it was a byte offset, so 1 bit was wasted because branching to an odd address is not
allowed (instructions are in multiples of 16 bits).
The 68020 added longer offsets by using the values (I think) of -1 and -3 in the branch offset to flag
that one or two words came after the instruction that were used for the branch offset.

I had an idea (I'm pretty sure it is not original) of using the following encoding for offsets/immediates:
Allocate an initial value (8 bits, 4 bits, whatever) in your instruction.
If the high bit is zero, the rest of the bits are you value (signed or unsigned, as is appropriate).
If the high bit is one, and the next bit is zero, one additional "chunk" (Instruction addressing granularity
of the ISA) is added. The resulting value is a concatenation of the chunk and the remaining value
bits in the initial value. Additional chunk values can be added by simple extension.

So, using the x86 as an example:
JC label
the opcode is (whatever, say 0x41 for now, I don't feel like looking it up)..
The offset takes up 1 byte if it is within +-63 (ish) bytes, and is encoded as 0b0xxxxxxx (where x bits are the offset value).
The offset takes up 2 bytes if it is within +-8K(ish) bytes, and is encoded as 0xb10xxxxxx xxxxxxxx (2 bytes of offset, 14 bits of offset value).
The offset takes up 3 bytes if it is within +1M(ish) bytes, and is encoded as 0xb110xxxxx xxxxxxxx xxxxxxxx (3 bytes, 21 bits of offset value).
etc.

If the x86 had adopted such a scheme initially, a lot of 6 byte jumps would just be 3 bytes.

The same scheme could be applied to addressing offsets & immediates.
For addressing offsets, you could also get a boost by saying that if it is just a small offset (the initial value in the instruction)
it is automatically scaled by the type size of the thing you are addressing.. If you want a byte offset using the
longer version. Again, this would compact code quite a bit because most things these days are type size aligned.

Note, I have no idea how much this complicates the instruction decoder, but the first encoded value
could be near the front of the instruction so the length decoding could happen early.

Also, this obviously has problems if there are two such values in the instruction, e.g.:
MOV Word Ptr [BP+offset], imm

- Tim

Re: Variable branch length encoding?

<590dca0c-52fc-4537-8eb6-647f6932e4e8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31200&group=comp.arch#31200

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5314:0:b0:3ce:618e:959 with SMTP id t20-20020ac85314000000b003ce618e0959mr128937qtn.4.1678897884219;
Wed, 15 Mar 2023 09:31:24 -0700 (PDT)
X-Received: by 2002:a05:6870:bb1a:b0:17a:bf87:63f4 with SMTP id
nw26-20020a056870bb1a00b0017abf8763f4mr1830011oab.11.1678897884002; Wed, 15
Mar 2023 09:31:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Wed, 15 Mar 2023 09:31:23 -0700 (PDT)
In-Reply-To: <1a969f26-7970-45a5-bc30-9581a2491459n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:c5ce:7c59:b7fe:6e76;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:c5ce:7c59:b7fe:6e76
References: <ttn1gq$3taue$1@dont-email.me> <1a969f26-7970-45a5-bc30-9581a2491459n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <590dca0c-52fc-4537-8eb6-647f6932e4e8n@googlegroups.com>
Subject: Re: Variable branch length encoding?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Wed, 15 Mar 2023 16:31:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5781
 by: MitchAlsup - Wed, 15 Mar 2023 16:31 UTC

On Wednesday, March 15, 2023 at 9:07:53 AM UTC-5, Timothy McCaffrey wrote:
> On Wednesday, March 1, 2023 at 3:14:22 AM UTC-5, Terje Mathisen wrote:
> > Would it be possible or just a bad idea to allow some form of
> > variable/fp encoding of branch offsets?
> >
> > I.e. all small (byte) offsets would be encoded directly, but for longer
> > ones you could require the target to be word/dword/qword aligned, and
> > therefore allow a much greater range.
> >
> > It would probably only be useful for inter-module calls/branches...
> >
> > The main problem is probably that the target address adder is already in
> > the critical path, so you can't just add a little shifter there as well..
> >
> > (Even though LEA r1,[r2+8*r3+0x12345678] is already doing some of this,
> > right?)
> >
> > Terje
> >
> The 68000 had a 16 bit conditional branch, 8 bits of which were a signed offset for the branch target.
> Annoyingly, it was a byte offset, so 1 bit was wasted because branching to an odd address is not
> allowed (instructions are in multiples of 16 bits).
> The 68020 added longer offsets by using the values (I think) of -1 and -3 in the branch offset to flag
> that one or two words came after the instruction that were used for the branch offset.
>
> I had an idea (I'm pretty sure it is not original) of using the following encoding for offsets/immediates:
> Allocate an initial value (8 bits, 4 bits, whatever) in your instruction.
> If the high bit is zero, the rest of the bits are you value (signed or unsigned, as is appropriate).
> If the high bit is one, and the next bit is zero, one additional "chunk" (Instruction addressing granularity
> of the ISA) is added. The resulting value is a concatenation of the chunk and the remaining value
> bits in the initial value. Additional chunk values can be added by simple extension.
>
> So, using the x86 as an example:
> JC label
> the opcode is (whatever, say 0x41 for now, I don't feel like looking it up).
> The offset takes up 1 byte if it is within +-63 (ish) bytes, and is encoded as 0b0xxxxxxx (where x bits are the offset value).
> The offset takes up 2 bytes if it is within +-8K(ish) bytes, and is encoded as 0xb10xxxxxx xxxxxxxx (2 bytes of offset, 14 bits of offset value).
> The offset takes up 3 bytes if it is within +1M(ish) bytes, and is encoded as 0xb110xxxxx xxxxxxxx xxxxxxxx (3 bytes, 21 bits of offset value).
> etc.
>
> If the x86 had adopted such a scheme initially, a lot of 6 byte jumps would just be 3 bytes.
>
> The same scheme could be applied to addressing offsets & immediates.
> For addressing offsets, you could also get a boost by saying that if it is just a small offset (the initial value in the instruction)
> it is automatically scaled by the type size of the thing you are addressing. If you want a byte offset using the
> longer version. Again, this would compact code quite a bit because most things these days are type size aligned.
>
> Note, I have no idea how much this complicates the instruction decoder, but the first encoded value
> could be near the front of the instruction so the length decoding could happen early.
>
> Also, this obviously has problems if there are two such values in the instruction, e.g.:
> MOV Word Ptr [BP+offset], imm
<
Why??
<
r8_erf: ; @r8_erf
; %bb.0:
add sp,sp,#-128
std #4614300636657501161,[sp,88] // a[0]
std #4645348406721991307,[sp,104] // a[2]
std #4659275911028085274,[sp,112] // a[3]
std #4595861367557309218,[sp,120] // a[4]
std #4599171895595656694,[sp,40] // p[0]
std #4593699784569291823,[sp,56] // p[2]
std #4580293056851789237,[sp,64] // p[3]
std #4559215111867327292,[sp,72] // p[4]
std #4580359811580069319,[sp,80] // p[4]
std #4612966212090462427,[sp] // q[0]
std #4602930165995154489,[sp,16] // q[2]
std #4588882433176075751,[sp,24] // q[3]
std #4567531038595922641,[sp,32] // q[4]
Although nothing prevented the address mode to use longer displacements.
The //s are my comments to myself, but in this case name the constant.
<
Nothing is preventing::
std #4614300636657501161,[ip,ri<<3,.L__const.r8_erf.c]
>
> - Tim

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor