Mill Computing, Inc. › Forums › The Mill › Architecture › switches › Reply To: switches
Sorry if it looks like I am spamming, the forum keeps deleting my post.
The pick operation can be used to build a range check. For example, to check if (x >=4 && x <= 7) one could write:
F("bar") %0;
rd (w(0ul)) %1,
geqs (b1 %0, 4) %2,
leqs (b2 %0, 7) %3,
pick (b1 %2, b0 %3, b2 %1) %4;
Range checks would be fairly common in switches. In this example, if (2 <= x && x <= 3) it should call foo(), and if (4 <= x && x <= 7) it can return x. It seems like a fairly simple optimization to add to the specializer instead of a bunch of eql. Range checks could also be useful to perform array bounds check.
The only issue, if I understand phasing correctly, is that the result of a pick cannot be used in a calltr1 within the same instruction.
I must admit I scratched my head about the fma operation. For the life of me I can’t imagine it being used that often. It seems like an oddly specific instruction to add, but maybe I am missing something. If you can have operations that use more than one ALU, then perhaps a “between” operation that does a range check would be useful. As shown above it can easily be done with a pick, but there could be a gain if the result of the between operation was usable in calltr1.