cmd/compile: detect divisions that always result in 0 #25733
Comments
@davecheney safe to assume this came from real code? Autogenerated? |
I'm afraid it's worse, this code came from a LLVM presentation, https://youtu.be/V6ug3e3jC54?t=3m22s |
This sounds like a job for prove pass. cc'ing @aclements and @rasky , since they recently were working on it. |
Change https://golang.org/cl/129759 mentions this issue: |
I don’t know if or when prove will do this kind of optimisation. In the meantime this is a simple fix for the specific issue. |
@davecheney I'm wondering about the expected utility of this optimization - what situations is it expected to arise in? How common are they? Is this explained in the presentation? Thanks. |
CL https://go-review.googlesource.com/c/go/+/129759/ hasn't had much movement since August 30th 2018 and due to the questions still pending, I shall punt this to "Unreleased" as Go1.12 will soon be out the door. Please feel free to revert my triaging if so. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +b7f3c178a3 Mon May 14 04:42:45 2018 +0000 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
What did you expect to see?
Something akin to
What did you see instead?
The value of q is in the range [0-6) because of the modulo, which divided by 9 is always 0. So the result of
f(x, y)
is alwaysx
The text was updated successfully, but these errors were encountered: