Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Bug 171: Remove integer promotions in unsigned right shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jan 17, 2015
1 parent df6ccf0 commit 2eabee4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions gcc/d/ChangeLog
@@ -1,3 +1,9 @@
2015-01-17 Iain Buclaw <ibuclaw@gdcproject.org>

* d-elem.cc(UshrExp::toElem): Remove integer promotions on left hand
side of unsigned right shift expression.
(UshrAssignExp::toElem): Ditto.

2015-01-13 Iain Buclaw <ibuclaw@gdcproject.org>

* d-system.h: Include hash-set.h, machmode.h, vec.h, double-int.h,
Expand Down
24 changes: 21 additions & 3 deletions gcc/d/d-elem.cc
Expand Up @@ -451,8 +451,17 @@ UshrExp::toElem (IRState *irs)
if (unhandled_arrayop_p (this))
return error_mark_node;

// Front-end integer promotions don't work here.
Expression *e1b = e1;
while (e1b->op == TOKcast)
{
CastExp *ce = (CastExp *) e1b;
gcc_assert(d_types_same(ce->type, ce->to));
e1b = ce->e1;
}

return build_binary_op (UNSIGNED_RSHIFT_EXPR, type->toCtype(),
e1->toElem (irs), e2->toElem (irs));
e1b->toElem (irs), e2->toElem (irs));
}

elem *
Expand Down Expand Up @@ -757,8 +766,17 @@ UshrAssignExp::toElem (IRState *irs)
if (unhandled_arrayop_p (this))
return error_mark_node;

tree exp = toElemBin (irs, UNSIGNED_RSHIFT_EXPR);
return convert_expr (exp, e1->type, type);
// Front-end integer promotions don't work here.
Expression *e1b = e1;
while (e1b->op == TOKcast)
{
CastExp *ce = (CastExp *) e1b;
gcc_assert(d_types_same(ce->type, ce->to));
e1b = ce->e1;
}

tree exp = build_binop_assignment(UNSIGNED_RSHIFT_EXPR, e1b, e2);
return convert_expr(exp, e1b->type, type);
}

elem *
Expand Down

0 comments on commit 2eabee4

Please sign in to comment.