Skip to content

cmd/compile: boolean operations not constant folded #32713

@mariecurried

Description

@mariecurried

What version of Go are you using (go version)?

$ go version
go version devel +c82e7e7 Tue Jun 18 22:21:45 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

I inspected the assembly code generated for the following functions:

func f1(b bool) bool {
    return b && !b
}
func f2(b bool) bool {
    return b || !b
}

What did you expect to see?

I expected them to be compiled to a simple return: false in the first case, true in the second.

What did you see instead?

Instead, boolean operations are performed on the variable b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions