3 ms·
The optimization I'm referring to is widening a 32-bit loop IV to 64-bit so it can stay in a register: https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690
by pcwalton 5y ago
The optimization I'm referring to is widening a 32-bit loop IV to 64-bit so it can stay in a register: https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7 https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759...
size_t obviates the need for this optimization.
- astrange 5y agoThat's a strange example since it doesn't prove their point. "int count; … for (int i = 0; i < count; ++i) {}" can't overflow so the optimization is always valid. "int count; … for (int i = 0; i < count; i += 2) {}" is more of a problem. I don't think "have a 64-bit int type" is the right approach for a new language either… we should be aiming for safety. If a variable's valid values are 0-50 then its type should be "integer between 0 and 50", not "integer between 0 and UINT64_MAX". Storage size should be an implementation detail.
- plq 5y agoADA has this exact functionality: https://www.adaic.org/resources/add_content/standards/05aarm/html/AA-3-5-4.html https://www.adaic.org/resources/add_content/standards/05aarm... Look for the "range" keyword