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

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 11 00:09:25 PDT 2020


craig.topper added inline comments.


================
Comment at: clang/lib/Headers/ia32intrin.h:421
+    if (__c != 0) {                                                            \
+      *(a) = (unsigned)__bsfd(__c);                                            \
+      __d = 1;                                                                 \
----------------
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 *?


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