Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: arm64Negate for floating point is not correct #43619

Closed
lijunchen opened this issue Jan 11, 2021 · 5 comments
Closed

cmd/compile: arm64Negate for floating point is not correct #43619

lijunchen opened this issue Jan 11, 2021 · 5 comments

Comments

@lijunchen
Copy link
Contributor

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

master

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

linux/arm64

What did you do?

package main

import (
        "fmt"
        "math"
)

//go:noinline
func test(a, b float64, x uint64) uint64 {
        if a < b {
                x = 0
        }
        return x
}

func main() {
        nan := math.NaN()
        fmt.Println(test(1, nan, 123))
}

What did you expect to see?

123

What did you see instead?

0

@lijunchen
Copy link
Contributor Author

I have figured out what happened, create this issue to get an issue id for writing a test file.

@davecheney
Copy link
Contributor

NaN is neither less than or greater than any number

https://play.golang.org/p/fYag0Dp6i0i

I don't think this is a bug.

@erifan
Copy link

erifan commented Jan 11, 2021

NaN is neither less than or greater than any number

Yes, you are right. So the above case really seems to be a bug.

@gopherbot
Copy link

Change https://golang.org/cl/283572 mentions this issue: cmd/compile: fix wrong complement for arm64 floating-point comparisons

@lijunchen
Copy link
Contributor Author

NaN is neither less than or greater than any number

https://play.golang.org/p/fYag0Dp6i0i

I don't think this is a bug.

If we disable optimization, the output is 123 as expected. So there must be something wrong, I submit a patch, please take a look, thanks.

$ go run -gcflags -N t.go
123

$ go run t.go
0

@golang golang locked and limited conversation to collaborators Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants