Repository: go
Issue: cmd/compile: missed optimization when using verbose array initialization
Labels: Performance,NeedsInvestigation,compiler/runtime

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version devel go1.20-8d57f4dcef Sat Aug 20 00:56:30 2022 +0000 linux/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes, reproduces with Go 1.19


### What operating system and processor architecture are you using (`go env`)?
linux/amd64

### What did you do?
```
package pkg

func pack1(id uint64) [5]byte {
	var b [5]byte
	b[0] = byte(id)
	b[1] = byte(id >> 8)
	b[2] = byte(id >> 16)
	b[3] = byte(id >> 24)
	b[4] = byte(id >> 32)

	return b
}

func pack2(id uint64) [5]byte {
	return [5]byte{
		byte(id),
		byte(id >> 8),
		byte(id >> 16),
		byte(id >> 24),
		byte(id >> 32),
	}
}
```

### What did you expect to see?
I expected both versions to compile the same.


### What did you see instead?
`pack2` is optimized better than `pack1`.

```
command-line-arguments.pack1 STEXT nosplit size=79 args=0x10 locals=0x10 funcid=0x0 align=0x0
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:3)      TEXT    command-line-arguments.pack1(SB), NOSPLIT|ABIInternal, $16-16
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:3)      SUBQ    $16, SP
        0x0004 00004 (/home/dominikh/prj/src/example.com/foo.go:3)      MOVQ    BP, 8(SP)
        0x0009 00009 (/home/dominikh/prj/src/example.com/foo.go:3)      LEAQ    8(SP), BP
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      FUNCDATA        $0, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      FUNCDATA        $1, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      FUNCDATA        $5, command-line-arguments.pack1.arginfo1(SB)
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      FUNCDATA        $6, command-line-arguments.pack1.argliveinfo(SB)
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      PCDATA  $3, $1
        0x000e 00014 (/home/dominikh/prj/src/example.com/foo.go:3)      MOVL    $0, command-line-arguments.~r0+24(SP)
        0x0016 00022 (/home/dominikh/prj/src/example.com/foo.go:3)      MOVB    $0, command-line-arguments.~r0+28(SP)
        0x001b 00027 (/home/dominikh/prj/src/example.com/foo.go:4)      MOVL    $0, command-line-arguments.b+3(SP)
        0x0023 00035 (/home/dominikh/prj/src/example.com/foo.go:4)      MOVB    $0, command-line-arguments.b+7(SP)
        0x0028 00040 (/home/dominikh/prj/src/example.com/foo.go:8)      MOVL    AX, command-line-arguments.b+3(SP)
        0x002c 00044 (/home/dominikh/prj/src/example.com/foo.go:9)      SHRQ    $32, AX
        0x0030 00048 (/home/dominikh/prj/src/example.com/foo.go:9)      MOVB    AL, command-line-arguments.b+7(SP)
        0x0034 00052 (/home/dominikh/prj/src/example.com/foo.go:11)     MOVL    command-line-arguments.b+3(SP), AX
        0x0038 00056 (/home/dominikh/prj/src/example.com/foo.go:11)     MOVBLZX command-line-arguments.b+7(SP), CX
        0x003d 00061 (/home/dominikh/prj/src/example.com/foo.go:11)     MOVL    AX, command-line-arguments.~r0+24(SP)
        0x0041 00065 (/home/dominikh/prj/src/example.com/foo.go:11)     MOVB    CL, command-line-arguments.~r0+28(SP)
        0x0045 00069 (/home/dominikh/prj/src/example.com/foo.go:11)     MOVQ    8(SP), BP
        0x004a 00074 (/home/dominikh/prj/src/example.com/foo.go:11)     ADDQ    $16, SP
        0x004e 00078 (/home/dominikh/prj/src/example.com/foo.go:11)     RET
        0x0000 48 83 ec 10 48 89 6c 24 08 48 8d 6c 24 08 c7 44  H...H.l$.H.l$..D
        0x0010 24 18 00 00 00 00 c6 44 24 1c 00 c7 44 24 03 00  $......D$...D$..
        0x0020 00 00 00 c6 44 24 07 00 89 44 24 03 48 c1 e8 20  ....D$...D$.H.. 
        0x0030 88 44 24 07 8b 44 24 03 0f b6 4c 24 07 89 44 24  .D$..D$...L$..D$
        0x0040 18 88 4c 24 1c 48 8b 6c 24 08 48 83 c4 10 c3     ..L$.H.l$.H....
command-line-arguments.pack2 STEXT nosplit size=26 args=0x10 locals=0x0 funcid=0x0 align=0x0
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     TEXT    command-line-arguments.pack2(SB), NOSPLIT|ABIInternal, $0-16
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     FUNCDATA        $0, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     FUNCDATA        $1, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     FUNCDATA        $5, command-line-arguments.pack2.arginfo1(SB)
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     FUNCDATA        $6, command-line-arguments.pack2.argliveinfo(SB)
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     PCDATA  $3, $1
        0x0000 00000 (/home/dominikh/prj/src/example.com/foo.go:14)     MOVL    $0, command-line-arguments.~r0+8(SP)
        0x0008 00008 (/home/dominikh/prj/src/example.com/foo.go:14)     MOVB    $0, command-line-arguments.~r0+12(SP)
        0x000d 00013 (/home/dominikh/prj/src/example.com/foo.go:15)     MOVL    AX, command-line-arguments.~r0+8(SP)
        0x0011 00017 (/home/dominikh/prj/src/example.com/foo.go:20)     SHRQ    $32, AX
        0x0015 00021 (/home/dominikh/prj/src/example.com/foo.go:15)     MOVB    AL, command-line-arguments.~r0+12(SP)
        0x0019 00025 (/home/dominikh/prj/src/example.com/foo.go:15)     RET
        0x0000 c7 44 24 08 00 00 00 00 c6 44 24 0c 00 89 44 24  .D$......D$...D$
        0x0010 08 48 c1 e8 20 88 44 24 0c c3                    .H.. .D$..
```