1
0
mirror of https://github.com/golang/go synced 2024-09-25 13:30:12 -06:00

another shift bug

R=r
OCL=19525
CL=19525
This commit is contained in:
Ken Thompson 2008-11-18 17:15:42 -08:00
parent 92a4fe1dd5
commit 93c8d3c41b

View File

@ -6,7 +6,6 @@
#undef EXTERN #undef EXTERN
#define EXTERN #define EXTERN
#include "gg.h" #include "gg.h"
//#include "opt.h"
enum enum
{ {
@ -93,11 +92,6 @@ if(throwreturn == N) {
gclean(); gclean();
checklabels(); checklabels();
// if(debug['N']) {
// regopt(ptxt);
// debug['N'] = 0;
// }
if(curfn->type->outtuple != 0) { if(curfn->type->outtuple != 0) {
gins(ACALL, N, throwreturn); gins(ACALL, N, throwreturn);
} }
@ -105,6 +99,11 @@ if(throwreturn == N) {
pc->as = ARET; // overwrite AEND pc->as = ARET; // overwrite AEND
pc->lineno = lineno; pc->lineno = lineno;
// if(debug['N']) {
// regopt(ptxt);
// debug['N'] = 0;
// }
// fill in argument size // fill in argument size
ptxt->to.offset = rnd(curfn->type->argwid, maxround); ptxt->to.offset = rnd(curfn->type->argwid, maxround);
@ -1212,7 +1211,13 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
if(nr->op == OLITERAL) { if(nr->op == OLITERAL) {
regalloc(&n1, nl->type, res); regalloc(&n1, nl->type, res);
cgen(nl, &n1); cgen(nl, &n1);
gins(a, nr, &n1); if(mpgetfix(nr->val.u.xval) >= nl->type->width*8) {
// large shift gets 2 shifts by width
nodconst(&n3, types[TUINT32], nl->type->width*8-1);
gins(a, &n3, &n1);
gins(a, &n3, &n1);
} else
gins(a, nr, &n1);
gmove(&n1, res); gmove(&n1, res);
regfree(&n1); regfree(&n1);
goto ret; goto ret;