Work around conservative optimization

Kagamin spam at here.lot
Sat Jun 2 10:40:43 UTC 2018


uint load32_le(in ref ubyte[4] s)
{
	return s[0] | (s[1]<<8) | (s[2]<<16) | (s[3]<<24);
}

void store32_le(ref ubyte[4] dest, uint val)
{
	dest[0]=cast(byte)val;
	dest[1]=cast(byte)(val>>8);
	dest[2]=cast(byte)(val>>16);
	dest[3]=cast(byte)(val>>24);
}

The first function is optimized to one load, but the second 
remains as 4 stores. Is there a code pattern that gets around 
this?


More information about the digitalmars-d-ldc mailing list