Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4e4097d9
Commit
4e4097d9
authored
Oct 15, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
386 shift bug; wasn't zero-extending 16- and 8-bit counts
+test R=ken OCL=35801 CL=35801
parent
a75e347a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
12 deletions
+46
-12
src/cmd/8g/cgen64.c
src/cmd/8g/cgen64.c
+8
-4
test/64bit.go
test/64bit.go
+38
-8
No files found.
src/cmd/8g/cgen64.c
View file @
4e4097d9
...
...
@@ -178,8 +178,10 @@ cgen64(Node *n, Node *res)
gins
(
ACMPL
,
&
hi2
,
ncon
(
0
));
p1
=
gbranch
(
AJNE
,
T
);
gins
(
AMOVL
,
&
lo2
,
&
cx
);
}
else
gins
(
AMOVL
,
r
,
&
cx
);
}
else
{
cx
.
type
=
types
[
TUINT32
];
gmove
(
r
,
&
cx
);
}
// if shift count is >=64, zero value
gins
(
ACMPL
,
&
cx
,
ncon
(
64
));
...
...
@@ -265,8 +267,10 @@ cgen64(Node *n, Node *res)
gins
(
ACMPL
,
&
hi2
,
ncon
(
0
));
p1
=
gbranch
(
AJNE
,
T
);
gins
(
AMOVL
,
&
lo2
,
&
cx
);
}
else
gins
(
AMOVL
,
r
,
&
cx
);
}
else
{
cx
.
type
=
types
[
TUINT32
];
gmove
(
r
,
&
cx
);
}
// if shift count is >=64, zero or sign-extend value
gins
(
ACMPL
,
&
cx
,
ncon
(
64
));
...
...
test/64bit.go
View file @
4e4097d9
...
...
@@ -459,12 +459,27 @@ const prolog =
"}
\n
"
"
\n
"
"func testInt64Shift(a int64, b uint64, left, right int64) {
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }
\n
"
" if uint64(uint(b)) == b {
\n
"
" b := uint(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint32(b)) == b {
\n
"
" b := uint32(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint16(b)) == b {
\n
"
" b := uint16(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint8(b)) == b {
\n
"
" b := uint8(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
"}
\n
"
"
\n
"
...
...
@@ -489,12 +504,27 @@ const prolog =
"}
\n
"
"
\n
"
"func testUint64Shift(a, b, left, right uint64) {
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }
\n
"
" if uint64(uint(b)) == b {
\n
"
" b := uint(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint32(b)) == b {
\n
"
" b := uint32(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint16(b)) == b {
\n
"
" b := uint16(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
" if uint64(uint8(b)) == b {
\n
"
" b := uint8(b);
\n
"
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }
\n
"
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }
\n
"
" }
\n
"
"}
\n
"
"
\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment