Skip to content

cmd/compile: ICE on arm64 due to missed constant folding #73200

Closed

Description

@randall77
package main

var g bool

func main() {
	l_4 := uint32(0x6E54EE87)
	v4 := int8(-Int64FromInt64(1))
	g = int32(v4) >= safe_mod_func_int32_t_s_s(BoolInt32(l_4 >= 1), 7)
}

func safe_mod_func_int32_t_s_s(si1 int32, si2 int32) (r int32) {
	var v1 int32
	if si2 == 0 {
		v1 = si1
	} else {
		v1 = si1 % si2
	}
	return v1
}

func Int64FromInt64(n int64) int64 {
	return n
}

func BoolInt32(b bool) int32 {
	if b {
		return 1
	}
	return 0
}

Causes the compiler to crash with

internal compiler error: 'main': FlagConstant op should never make it to codegen v30 = FlagConstant <flags>[N=false,Z=false,C=false,V=false]

Activity

  1. added this to the Go1.25 milestone on Apr 7, 2025
  2. self-assigned this
    on Apr 7, 2025
  3. added theissue type on Apr 7, 2025
  4. gopherbot commented on Apr 7, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/663535 mentions this issue: cmd/compile: add additional flag constant folding rules

  5. gabyhelp commented on Apr 7, 2025

    @gabyhelp

    Related Issues

    (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

  6. added
    BugReportIssues describing a possible bug in the Go implementation.
    on Apr 7, 2025
  7. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Apr 7, 2025
  8. added a commit that references this issue on Apr 8, 2025
    af278bf
  9. locked and limited conversation to collaborators on Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgearch-arm64compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions