OS X Mach-O assembler /usr/bin/as rejects the popcntq instruction

OS X Mach-O assembler /usr/bin/as rejects the popcntq instruction

Apple claims this is your problem, not theirs (see bottom of this post). I couldn't find anything related by searching this forum.
Summary: The OS X Mach-O assembler /usr/bin/as rejects assembly code that uses the popcntq instruction.Steps to Reproduce:
1) Create the assembly-language program test.s (included in the Notes section) by using icc -S -xSSE4.2 -o test.s test.c to compile the following:

/* test.c */ #include int main() { int bits_set; long qword = 0xFEDCBA9876543210; bits_set = __builtin_popcountl(qword); printf("%d bits are set.n", bits_set); return 0; }
2) Invoke /usr/bin/as test.sExpected Results: The creation of a Mach-O file named a.outActual Results: test.c:18:suffix or operands invalid for `popcnt'Notes:
1) /usr/bin/as -vApple Inc version cctools-782~29, GNU assembler version 1.382)
# -- Machine type EFI2 # mark_description "Intel C Intel 64 Compiler XE for applications running on Intel 64, Version Build 2010111"; # mark_description "0"; # mark_description "-S -xSSE4.2 -o test.s"; .file "test.c" .section __TEXT, __text L_TXTST0: # -- Begin _main # mark_begin; .align 4 .globl _main _main: L_B1.1: # Preds L_B1.0 L____tag_value__main.1: #5.1 pushq %rbp #5.1 L____tag_value__main.3: # movq %rsp, %rbp #5.1 L____tag_value__main.4: # andq $-128, %rsp #5.1 subq $128, %rsp #5.1 movl $3, %edi #5.1 call ___intel_new_proc_init_H #5.1 # LOE rbx r12 r13 r14 r15 L_B1.5: # Preds L_B1.1 stmxcsr (%rsp) #5.1 movq $0xfedcba9876543210, %rdx #11.14 lea L_2__STRING.0(%rip), %rdi #13.3 popcntq %rdx, %rsi #11.14 xorl %eax, %eax #13.3 orl $32832, (%rsp) #5.1 ldmxcsr (%rsp) #5.1 call _printf #13.3 # LOE rbx r12 r13 r14 r15 L_B1.2: # Preds L_B1.5 xorl %eax, %eax #15.10 movq %rbp, %rsp #15.10 popq %rbp #15.10 L____tag_value__main.6: # ret #15.10 .align 4 L____tag_value__main.8: # # LOE # mark_end; .section __DATA, __data # -- End _main .cstring .align 2 .align 2 L_2__STRING.0: .byte 37 .byte 100 .byte 32 .byte 98 .byte 105 .byte 116 .byte 115 .byte 32 .byte 97 .byte 114 .byte 101 .byte 32 .byte 115 .byte 101 .byte 116 .byte 46 .byte 10 .byte 0 .section __DATA, __data .globl _main.eh // -- Begin SEGMENT __eh_frame .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support __eh_frame_seg: L.__eh_frame_seg: EH_frame0: L_fde_cie_0: .long 0x00000014 .long 0x00000000 .long 0x00527a01 .long 0x01107801 .long 0x08070c10 .long 0x00000190 _main.eh: .long 0x0000003c .long _main.eh-L_fde_cie_0+0x4 .quad L____tag_value__main.1-_main.eh-0x8 .set L_Qlab1,L____tag_value__main.8-L____tag_value__main.1 .quad L_Qlab1 .long 0x00000008 .long 0x00000000 .short 0x0400 .set L_lab1,L____tag_value__main.3-L____tag_value__main.1 .long L_lab1 .short 0x100e .byte 0x04 .set L_lab2,L____tag_value__main.4-L____tag_value__main.3 .long L_lab2 .long 0x8610060c .short 0x0402 .set L_lab3,L____tag_value__main.6-L____tag_value__main.4 .long L_lab3 .long 0x0908070c .long 0x00000606 .byte 0x00 # End .subsections_via_symbols 
Response from Apple:
10-Aug-2010 01:02 PM [Name Removed]:
Engineering has determined that this issue originates with the icc compiler. Please contact its developers regarding this issue to help alert them of its importance.
The assembler accepts popcnt without the 'q' suffix. It has never accepted the 'q' or any of the other suffixes for the different forms.
We are closing this bug report because it is up to a 3rd party to resolve.

10 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Thanks for reporting the issue and with a testcase/steps!
I duplicated the issue and have filed a bug repor to the compiler team (DPD200164794). When I got any update info, I'll let you know.

Sorry that it took so long torespond.

Thanks again!

Update to this issue. it is fixed in the 12.1 compiler or newer.


>>...Update to this issue. it is fixed in the 12.1 compiler or newer.

There are 7 Updates for that version and could you confirm that the last Update 7 has the fix? Thanks.

By the way, I don't see that a compiler option -m64 was used in the first place.


Sergey Kostrov wrote:

There are 7 Updates for that version and could you confirm that the last Update 7 has the fix? Thanks.

All updates of 12.1 has this fix.

Duplicate - removed.

Attached is a test case to verify the compilation of a source file with usage of the instruction ( inline assembler ) and with intrinsic functions on Windows platforms.


Downloadtext/x-c++src AsmTestApp.cpp1.95 KB

The following error was displayed:

Error messageThe specified file public://AsmTestApp.cpp could not be copied, because no file by that name exists. Please check that you supplied the correct filename.

Attached is a screenshot with an AJAX Http Request Error:


Downloadimage/jpeg ajaxerror.jpg76.97 KB

Leave a Comment

Please sign in to add a comment. Not a member? Join today