LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1095 - Miscompilation of asm("{cntlz|cntlzw} %0, %1" ...) on PowerPC
Summary: Miscompilation of asm("{cntlz|cntlzw} %0, %1" ...) on PowerPC
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: trunk
Hardware: Macintosh MacOS X
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-07 16:45 PST by Bill Wendling
Modified: 2010-02-22 12:53 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Wendling 2007-01-07 16:45:03 PST
On my PowerBook G4, compiling this program:

#include <stdio.h>

int main()
{
  unsigned long int ctz_x = 0x0000f000;
  unsigned long int ctz_c;

  __asm__("{cntlz|cntlzw} %0,%1"
          : "=r" (ctz_c)
          : "r" (ctz_x & -ctz_x));

  printf("ctz_c == %d\n", ctz_c);
  return 0;
}

results in the use of the mnemonic "cntlz" instead of "cntlzw". This produces an error when trying to 
assemble the program:

  cntlzw_miscompile.s:25:Invalid mnemonic 'cntlz'

GCC outputs "cntlzw" instead.

-bw
Comment 1 Bill Wendling 2007-01-07 16:48:34 PST
This was found when trying to compile "gmp".