[PATCH] D75723: [X86] Enable intrinsics _BitScan*

Kan Shengchen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 11 01:36:00 PDT 2020


skan marked an inline comment as done.
skan added inline comments.


================
Comment at: clang/lib/Headers/ia32intrin.h:421
+    if (__c != 0) {                                                            \
+      *(a) = (unsigned)__bsfd(__c);                                            \
+      __d = 1;                                                                 \
----------------
craig.topper wrote:
> skan wrote:
> > craig.topper wrote:
> > > Should (a) have a cast to (unsigned *)?
> > No. Using a cast here may cause pointer aliasing problem. 
> > 
> > https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule
> > 
> > If a is not `unsigned *`, letting the compiler do auto integer conversion for `*(a)` is the correct way, from my perspective.
> But if we implemented this as an inline function instead of a macro wouldn't the argument have been an unsigned *?
Yes, it would have been.  But I don't known the motivation to use a cast `(unsigned *)` here,  is there any case using cast here works correctly while not using cast here fails?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75723/new/

https://reviews.llvm.org/D75723





More information about the cfe-commits mailing list