Closed jakobkummerow closed 3 years ago
I wonder how future-proof this particular way of tricking the compiler is — is there any way this might one day no longer be sufficient?
I think it's reasonably future-proof, though as always it's hard to make predictions with absolute certainty :-)
The only way to be 100% bulletproof would be to use/check every single computed result, but I don't want to introduce that much overhead (since we're measuring individual operations, adding an additional comparison would be ~50% of the total workload), especially as long as it isn't necessary.
For some operations, like add
and sub
, we could work around it by turning the test into a chain of operations, i.e. using the last result as one of the two inputs. But for bitwiseAnd
and bitwiseOr
, that approach would quickly lead to a rather boring all-0-bits or all-1-bits result, so it's not generally applicable.
I think pragmatically, if we notice that it breaks, we'll just fix it again. Maybe JSBI will be deprecated before that happens :-)
Thanks for the review!