On 10/27/15 12:04 PM, tsbockman wrote:
On Tuesday, 27 October 2015 at 12:28:38 UTC, Steven Schveighoffer wrote:
On 10/26/15 1:08 PM, tsbockman wrote:
My solution #2 is the same as the one you proposed - the dummy parameter
stuff is my vague proposal for a way to actual implement this behavior
in the compiler.
The halting problem is no more of an issue than it is for the compiler
today. (That is to say, the halting problem leads to false negatives,
but not false positives.)
OK, as long as the default behavior isn't to reject the code, I
suppose this is simply an optimization.
Right.
But the problem I see is that only static ifs that reduce to static
if(true) would be considered to cause a short-circuit (e.g. someint <=
int.max). Unless the compiler can VRP according to the template
constraint, which may be possible in simple circumstances, but not in
all circumstances.
I think the next piece of Lionello Lunesu's PR which I am updating might
actually do that; I'll have to check later. Regardless, you are correct
solution #1 will substantially reduce the opportunities for constant
folding.
I'm not a compiler dev, so I'm not sure how it works or should work. I'm
looking at this from a user standpoint.
I didn't consider that the compiler is likely already using VRP to
determine whether a line of code is unnecessary. If it's a matter of
just keeping track of 2 VRP ranges (the actual VRP and the VRP just for
checking reachability) for each line of code, then perhaps it's just
easier to extend VRP. I don't know the answer.
All I was saying is that it's not necessary to add on an additional
layer if it's not present.
I defer to the actual devs as to what is easier.
-Steve