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
Assignees

Comments

@lijunchen
Copy link
Contributor

@lijunchen lijunchen commented Jan 11, 2021

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

@lijunchen lijunchen commented Jan 11, 2021

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

@davecheney
Copy link
Contributor

@davecheney davecheney commented Jan 11, 2021

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
Contributor

@erifan 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

@gopherbot gopherbot commented Jan 13, 2021

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

@lijunchen
Copy link
Contributor Author

@lijunchen lijunchen commented Jan 13, 2021

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
@gopherbot gopherbot closed this in d9b79e5 Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.