[PATCH][X86] __builtin_ctz/clz sometimed defined for zero input

Joerg Sonnenberger joerg at britannica.bec.de
Mon Oct 27 11:52:49 PDT 2014


On Mon, Oct 27, 2014 at 04:45:02PM +0000, Robinson, Paul wrote:
> > Expose the llvm.cttz /llvm.ctlz with 1 as second argument as new
> > __builtin_cttz / __builtin_ctlz builtins and teach people to use those?
> > 
> > Joerg
> 
> So the new ones would unconditionally indicate "defined for zero" and we'd
> make the old ones unconditionally indicate "undef for zero"?  That still
> lets us eliminate the ForZeroUndef predicates, and if we fix lzcntintrin.h
> to use the new ones that fixes the miscompile problem; but I have to wonder
> about introducing a miscompile for ARM/PPC/MIPS users of the old builtin.

I am ambivalent about the behavior on platforms where the instructions
*always* had well-defined semantic. Keep in mind that X86 does not fall
into that category.

Joerg



More information about the cfe-commits mailing list