Skip to content

Commit

Permalink
Merge pull request #3934 from yebblies/issue13383
Browse files Browse the repository at this point in the history
Issue 13383 - wrong code with -O with ints, longs and bitwise operations
  • Loading branch information
WalterBright authored and 9rnsr committed Sep 3, 2014
1 parent 88925ef commit d1a3b4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/backend/cgelem.c
Expand Up @@ -1445,12 +1445,14 @@ STATIC elem * elbitwise(elem *e, goal_t goal)
* b btst a
*/
if (e1->Eoper == OPshl &&
ELCONST(e1->E1,1))
ELCONST(e1->E1,1) &&
tysize(e->E1->Ety) <= REGSIZE)
{
e->Eoper = OPbtst;
e->Ety = OPbool;
e->Ety = TYbool;
e->E1 = e2;
e->E2 = e1->E2;
e->E2->Ety = e->E1->Ety;
e1->E2 = NULL;
el_free(e1);
return optelem(e, goal);
Expand Down
14 changes: 14 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -891,6 +891,19 @@ void testbt()

////////////////////////////////////////////////////////////////////////

void test13383()
{
foreach (k; 32..33)
{
if (1L & (1L << k))
{
assert(0);
}
}
}

////////////////////////////////////////////////////////////////////////

int andand1(int c)
{
return (c > 32 && c != 46 && c != 44
Expand Down Expand Up @@ -1231,6 +1244,7 @@ int main()
testandand();
testor_combine();
testshrshl();
test13383();
test13190();
test10639();
test10715();
Expand Down

0 comments on commit d1a3b4e

Please sign in to comment.