Why is there no instruction rescheduling?

199 views
Skip to first unread message

Richard Gong

unread,
May 5, 2020, 11:18:28 PM5/5/20
to golang-nuts
I've been diving into golang compiler recently. As to the optimizations, I didn't find any pass implemented instruction rescheduling to utilize VLIW or pipeline technology in modern CPUs. 
Why this feature is missed?
Anybody have a clue?

Thanks in advance.

Ian Lance Taylor

unread,
May 5, 2020, 11:50:57 PM5/5/20
to Richard Gong, golang-nuts
The Go gc compiler is a fairly new compiler. There are many complex
optimizations that are missing. Instruction scheduling is hard, and
it hasn't been implemented. Serious proposals welcome, from people
willing and able to do the work.

It's also worth noting that the most popular CPU on which Go is used
is certainly amd64, and as far as I know all current amd64 processors
support out-of-order execution. Instruction scheduling can still
produce better code on amd64, but the opportunity for improvement is
fairly limited. Scheduling would be a much bigger optimization on ARM
or PPC processors. On amd64 there are a lot of currently missing
optimizations that I think would provide a better benefit for the
implementation cost.

Also for the Go gc compiler compilation time is an important goal.

Note that gccgo and GoLLVM are Go compilers that do support
instruction scheduling.

Ian

Richard Gong

unread,
May 6, 2020, 3:32:18 AM5/6/20
to golang-nuts
Thank you for your information, Ian.

Yes, I noticed that the optimization passes are concise as compared to other compilers, especially those "Sea of Nodes" compilers. Gc's escape analysis and inlining were based on AST. Do you think it's a drawback for deeper optimization?  Any future plan to upgrade the algorithm? 

Richard

Ian Lance Taylor

unread,
May 6, 2020, 2:23:50 PM5/6/20
to Richard Gong, golang-nuts
On Wed, May 6, 2020 at 12:32 AM Richard Gong <gon...@gmail.com> wrote:
>
> Yes, I noticed that the optimization passes are concise as compared to other compilers, especially those "Sea of Nodes" compilers. Gc's escape analysis and inlining were based on AST. Do you think it's a drawback for deeper optimization? Any future plan to upgrade the algorithm?

I'm sorry, I'm not sure quite what you are asking. Are you asking
whether the gc compiler could do better escape analysis or inlining if
they were done in the SSA form? It's possible.

There is continuous ongoing work on the gc compiler in every release.
It's one of the most active parts of the source tree. Go is an open
source project and everybody is welcome to participate.

Ian




> On Wednesday, May 6, 2020 at 11:50:57 AM UTC+8, Ian Lance Taylor wrote:
>>
>> On Tue, May 5, 2020 at 8:18 PM Richard Gong <gon...@gmail.com> wrote:
>> >
>> > I've been diving into golang compiler recently. As to the optimizations, I didn't find any pass implemented instruction rescheduling to utilize VLIW or pipeline technology in modern CPUs.
>> > Why this feature is missed?
>> > Anybody have a clue?
>>
>> The Go gc compiler is a fairly new compiler. There are many complex
>> optimizations that are missing. Instruction scheduling is hard, and
>> it hasn't been implemented. Serious proposals welcome, from people
>> willing and able to do the work.
>>
>> It's also worth noting that the most popular CPU on which Go is used
>> is certainly amd64, and as far as I know all current amd64 processors
>> support out-of-order execution. Instruction scheduling can still
>> produce better code on amd64, but the opportunity for improvement is
>> fairly limited. Scheduling would be a much bigger optimization on ARM
>> or PPC processors. On amd64 there are a lot of currently missing
>> optimizations that I think would provide a better benefit for the
>> implementation cost.
>>
>> Also for the Go gc compiler compilation time is an important goal.
>>
>> Note that gccgo and GoLLVM are Go compilers that do support
>> instruction scheduling.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0546099c-5100-4a9e-bbd8-2e112a3f9033%40googlegroups.com.

cheng dong

unread,
May 8, 2020, 2:56:22 PM5/8/20
to golang-nuts
i think it is because the go designer want to keep the memory order model of golang simple 

Ian Lance Taylor

unread,
May 8, 2020, 3:06:59 PM5/8/20
to cheng dong, golang-nuts
On Fri, May 8, 2020 at 11:56 AM cheng dong <qq451...@gmail.com> wrote:
>
> i think it is because the go designer want to keep the memory order model of golang simple

That turns out not to be the case. Go's memory model
(https://golang.org/ref/mem) permits instruction scheduling. As I
mentioned earlier, the gccgo and GoLLVM implementations Go do
instruction scheduling.

Ian


> On Wednesday, May 6, 2020 at 11:18:28 AM UTC+8, Richard Gong wrote:
>>
>> I've been diving into golang compiler recently. As to the optimizations, I didn't find any pass implemented instruction rescheduling to utilize VLIW or pipeline technology in modern CPUs.
>> Why this feature is missed?
>> Anybody have a clue?
>>
>> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7335d8fe-508c-49e9-b137-d24f511719d5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages