Skip to content

cmd/compile: ICE on 386 when inlining nested bit rotations (Int64Lo not lowered) #81687

Closed

Description

@JoTurk

Go version

go version go1.27.0 linux/amd64, targeting GOARCH=386.

Output of go env in your module/workspace:

"CGO_ENABLED": "0",
"GO386": "sse2",
"GOARCH": "386",
"GOEXPERIMENT": "",
"GOFLAGS": "",
"GOHOSTARCH": "amd64",
"GOHOSTOS": "linux",
"GOOS": "linux",
"GOVERSION": "go1.27.0"

What did you do?

repro.go:

package main

func rotate(x uint32, n int) uint32 {
	if n < 0 {
		s := uint(-n)
		return x<<s | x>>(32-s)
	}
	s := uint(n)
	return x>>s | x<<(32-s)
}

func main() {
	println(rotate(rotate(12345, 7), -7))
}

Run:

GOTOOLCHAIN=go1.27.0 GOARCH=386 go build repro.go

What did you see happen?

GOTOOLCHAIN=go1.27.0 GOARCH=386 go build repro.go

command-line-arguments

./repro.go:14:1: internal compiler error: 'main': not lowered: v35, Int64Lo UINT32 UINT64

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

compiles correctly

Activity

  1. JoTurk commented on Sep 23, 2026

    @JoTurk
    ContributorAuthor

    I ran git bisect from go1.27.0 to go1.26.0, and found that the ICE bisects to this commit 8dcb317

  2. gopherbot commented on Sep 23, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/837245 mentions this issue: cmd/compile: use a 32-bit type for rewritten rotate amounts

  3. thepudds commented on Sep 23, 2026

    @thepudds
    Member

    FWIW, this exact example seems to no longer cause a problem on latest master:

      GOOD master:   a532f497dc | 2026-09-22 22:23 | spec: fixes typo in alias declaration example
      first FIX:     5bec0d2b8f | 2026-08-07 01:52 | cmd/compile/internal/ssa: constant fold math/bits functions
    

    However, that constant folding might just be masking the underlying problem.

    If I change the first arg in the first rotate call to be a variable rather than a constant, it seems to still ICE on master:

    package main
    
    func rotate(x uint32, n int) uint32 {
    	if n < 0 {
    		s := uint(-n)
    		return x<<s | x>>(32-s)
    	}
    	s := uint(n)
    	return x>>s | x<<(32-s)
    }
    
    var x uint32 = 12345
    
    func main() {
    	println(rotate(rotate(x, 7), -7))
    }

    CC @Jorropo (for 8dcb317, if interested)

  4. changed the title [-]Go 1.27 ICE on 386 when inlining nested bit rotations (Int64Lo not lowered)[/-] [+]cmd/compile: ICE on 386 when inlining nested bit rotations (Int64Lo not lowered)[/+] on Sep 23, 2026
  5. Jorropo commented on Sep 23, 2026

    @Jorropo
    Member

    cc @gopherbot please open backport issues for 1.27
    Can lead to compiler crashes for valid code on 32bits arches.

  6. gopherbot commented on Sep 23, 2026

    @gopherbot
    Contributor

    Backport issue(s) opened: #81706 (for 1.27).

    Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

  7. added a commit that references this issue on Sep 24, 2026
    6b3800e
  8. added this to the Go1.28 milestone on Sep 29, 2026
  9. gopherbot commented on Sep 30, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/842565 mentions this issue: [release-branch.go1.27] cmd/compile: use a 32-bit type for rewritten rotate amounts

  10. gopherbot commented on Oct 6, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/845966 mentions this issue: [release-branch.go1.26] cmd/compile: use a 32-bit type for rewritten rotate amounts

  11. JunyangShao commented on Oct 27, 2026

    @JunyangShao
    Contributor

    @gopherbot please open backport issues for 1.26

  12. gopherbot commented on Oct 27, 2026

    @gopherbot
    Contributor

    Backport issue(s) opened: #82642 (for 1.26).

    Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions