Skip to content

Comments

Explicitly truncate/widen shift value in OptimizeVisitor::PowExp#4212

Merged
WalterBright merged 1 commit intodlang:masterfrom
ibuclaw:shiftcast
Dec 14, 2014
Merged

Explicitly truncate/widen shift value in OptimizeVisitor::PowExp#4212
WalterBright merged 1 commit intodlang:masterfrom
ibuclaw:shiftcast

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Dec 13, 2014

In certain scenarios, a ^^ expression may be wider or narrower than the default tshiftcnt type (int).

Example:

foreach(i; 1..table.length - 1)
  immutable strideLength = 2 ^^ i;

As I've brought up in previous PRs, this kind of type punning in the front-end IR doesn't sit too well with strict type-checked backend, so adding in an explicit cast fixes tree verification ICE's I'm seeing in gdc-5.0.

@ibuclaw
Copy link
Member Author

ibuclaw commented Dec 13, 2014

In case it isn't obvious, this area optimises 2UL ^^ i into 1UL << cast(int)(i * 1UL).

WalterBright added a commit that referenced this pull request Dec 14, 2014
Explicitly truncate/widen shift value in OptimizeVisitor::PowExp
@WalterBright WalterBright merged commit 8e4a404 into dlang:master Dec 14, 2014
@ibuclaw ibuclaw deleted the shiftcast branch April 12, 2015 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants