Requested by Richard Townsend at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1e4130b9720e4f2a
LEADZ and TRAILZ are rather common vendor extensions, e.g. supported by the Intel compiler (it also allows for logical arguments). LEADZ (I) Description. Number of leading zero bits. Argument. I shall be of type integer. Result Value. If all of the bits of I are zero, the result value is BIT SIZE (I). [...] TRAILZ (I) Description. Number of trailing zero bits. Argument. I shall be of type integer. The implementation should be relatively easy using the following built-ins, however, one presumably needs a special case for ZERO. BUILT_IN_CLZ* "These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined." and BUILT_IN_CTZ* "These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined." (Description copied from http://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html) For compile-time simplification, MPFR does not seem to provide a ready-to-use function; if one cooks up something oneself, one needs to check endian issues (though there might be none). -- Summary: Fortran 2008: Support LEADZ / TRAILZ Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37635