/ go Public
cmd/compile: unnecessary shift-check #48213
Issues related to the Go compiler and/or runtime.
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
Does this issue reproduce with the latest release?
What did you do?
See https://go.godbolt.org/z/o5PqscasE for code.
On line 11/12 panics when
endreg, is bigger than 29.
On line 15 it is checked that
On line 16 there is a branch that panics on negative
This might make sense if
hcould be -128, but it cant because of the check on line 11.
What did you expect to see?
I expected the go compiler to combine these checks and to avoid the extra branch+2 instructions.
What did you see instead?
Out of the assembly I gather that the go compiler fails to link line 15 with 16.
The gc also check the same thing twice, it also fails to see that
h < 0is the same as
-h >= 0.
https://go.godbolt.org/z/hsMnMa1W1 does what I expect, and the gc manages to proof that
-his less than
0x1f, but more importantly also that
The text was updated successfully, but these errors were encountered: