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

Kan Shengchen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 23:25:42 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:
> 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.


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