The pick 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 <= 3) it should call foo(), and if (4 <= 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 is that, if I understand the phasing correctly, the result of the pick cannot be used in the calltr1 within the same instruction.
I must admit I scratched my head a bit 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 use more than one ALU, then perhaps a “between” operation would be useful that would do range check. 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.
- This reply was modified 4 years, 9 months ago by goldbug.