title: Are gcc __builtin functions guaranteed to be replaced by matching assembly instructions?
body: <p>On ARM Cortex-M3, for example, <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/BABBBJGA.html" rel="noreferrer">CLZ instruction is present</a>, it counts leading zeros of an 32 bit integer.
  If integer is zero, result is 32.</p>
  
  <p>In gcc, on the other hand, I can use a __builtin_clz function. However, according to gcc documentation:</p>
  
  <blockquote>
    <p>Built-in Function: int __builtin_clz (unsigned int x).<br>
    Returns the number of leading 0-bits in x, starting at the most significant bit position. <strong>If x is 0, the result is undefined</strong>.</p>
  </blockquote>
  
  <p>So if using this builtin I should manually handle zero? Or is it guaranted to be compiled to CLZ instruction if such an instruction is present on target machine?</p>
  
  <p>Quotes from gcc documentation are highly appritiated!</p>