Fixed bmiintrin.h in r221065. Thanks for pointing it out. I also added the Intel documented names for these intrinsics in r221066.
On Sat, Nov 1, 2014 at 3:47 PM, Robinson, Paul < [email protected]> wrote: > Thanks. I've been trying to do this today but having trouble getting to > my work systems from home. > > Are there __builtin_ctz* calls (in bmiintrin.h or whatever) that assume > they > have tzcnt, and are also missing guards? > --paulr > > > -----Original Message----- > > From: [email protected] [mailto:cfe-commits- > > [email protected]] On Behalf Of Craig Topper > > Sent: Saturday, November 01, 2014 3:25 PM > > To: [email protected] > > Subject: r221064 - Avoid undefined behavior in the x86 lzcnt header file > > by explicitly checking for 0 before calling __builtin_clz. Without this > > the optimizers may take advantage of the undefined behavior and produce > > incorrect results. LLVM itself still needs t... > > > > Author: ctopper > > Date: Sat Nov 1 17:25:23 2014 > > New Revision: 221064 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=221064&view=rev > > Log: > > Avoid undefined behavior in the x86 lzcnt header file by explicitly > > checking for 0 before calling __builtin_clz. Without this the optimizers > > may take advantage of the undefined behavior and produce incorrect > > results. LLVM itself still needs to be taught to merge the zero check > into > > the llvm.ctlz with defined zero behavior. > > > > Modified: > > cfe/trunk/lib/Headers/lzcntintrin.h > > > > Modified: cfe/trunk/lib/Headers/lzcntintrin.h > > URL: http://llvm.org/viewvc/llvm- > > > project/cfe/trunk/lib/Headers/lzcntintrin.h?rev=221064&r1=221063&r2=221064 > > &view=diff > > > ========================================================================== > > ==== > > --- cfe/trunk/lib/Headers/lzcntintrin.h (original) > > +++ cfe/trunk/lib/Headers/lzcntintrin.h Sat Nov 1 17:25:23 2014 > > @@ -35,20 +35,20 @@ > > static __inline__ unsigned short __attribute__((__always_inline__, > > __nodebug__)) > > __lzcnt16(unsigned short __X) > > { > > - return __builtin_clzs(__X); > > + return __X ? __builtin_clzs(__X) : 16; > > } > > > > static __inline__ unsigned int __attribute__((__always_inline__, > > __nodebug__)) > > __lzcnt32(unsigned int __X) > > { > > - return __builtin_clz(__X); > > + return __X ? __builtin_clz(__X) : 32; > > } > > > > #ifdef __x86_64__ > > static __inline__ unsigned long long __attribute__((__always_inline__, > > __nodebug__)) > > __lzcnt64(unsigned long long __X) > > { > > - return __builtin_clzll(__X); > > + return __X ? __builtin_clzll(__X) : 64; > > } > > #endif > > > > > > > > _______________________________________________ > > cfe-commits mailing list > > [email protected] > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > -- ~Craig
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
