Some trivial binary operations that never had an expression in C/C++, I'd love consideration for an operator or some sort of intrinsic for these.<div><br></div><div><b>Roll/Rotate:</b> I'm loving the '>>>' operator, but I could often really do with a rotate operator useful in many situations... '>>|' perhaps... something like that?</div>
<div>  This is ugly: a = (a << x) | ((unsigned)a >> (sizeof(a)/8 - x)); ... and I'm yet to see a compiler that will interpret that correctly.</div><div>  Additionally, if a vector type is every added, a rotate operator will become even more useful.</div>
<div><br></div><div><b>Count leading/trailing zeroes:</b> I don't know of any even slightly recent architecture that doesn't have opcodes to count loading/trailing zeroes, although they do exist, so perhaps this is a little dubious. I'm sure this could be emulated for such architectures, but it might be unreasonably slow if used...</div>
<div><br></div><div><b>Min/Max operators:</b> GCC has the lovely <? and >? operators... a <? b == min(a, b) .. Why this hasn't been adopted by all C compilers is beyond me. Surely this couldn't be much trouble to add? Again, super useful in vector/maths heavy code too.</div>
<div><br></div><div><b>Predecated selection:</b> Float, vector, and often enough even int math can really benefit from using hardware select opcodes to avoid loads/stores. In C there is no way to express this short of vendor specific intrinsics again. 'a > b ? a : b' seems like a simple enough expression for the compiler to detect potential for a predecated select opcode (but in my experience, it NEVER does), however, when considering vector types, the logic isn't so clear in that format. Since hardware vectors implement component-wise selection, the logical nature of the ?: operator doesn't really make sense.</div>
<div>  This could easily be considered an expansion of min/max... 'a <? b', 'a >? b', 'a ==? b', 'a !=? b', etc. seems pretty natural if you're happy to accept GCC's '<?' operators, and give the code generator the opportunity to implement these things using hardware support.</div>
<div><br></div><div><br></div><div>C is terrible at expressing these concepts, resulting in architecture/compiler specific intrinsics for each of them. Every time I've ever written a maths library, or even just optimised some maths heavy routines, these things come up, and I end up with code full of architecture/platform/compiler ifdef's. I'd like to think they should be standardised intrinsic features of the language (not implemented in the standard library), so the code generator/back end has the most information to generate proper code...</div>
<div><br></div><div>Cheers guys</div><div>- Manu</div>