[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

Ayke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 16:12:32 PST 2021


aykevl added a comment.

I checked this, and it seems good to me although I would like someone else to also take a look.

In D86547#2287353 <https://reviews.llvm.org/D86547#2287353>, @atrosinenko wrote:

> In D86547#2284095 <https://reviews.llvm.org/D86547#2284095>, @MaskRay wrote:
>
>> The `(aWidth - 1) - clzsi(a)` change is correct, but why is the ctz change?
>
> `d.s.low` and `d.s.high` are `su_int`. While some helpers from `libgcc` are documented with `int`, `long`, etc. types //for simplicity// and use machine modes under the hood, the `__builtin_ctz()` function (as well as clz), on the other hand, seems to **really** accept an `int`-sized argument:

I can confirm this. This is why I introduced the `clzsi` and `ctzsi` macros in D78662 <https://reviews.llvm.org/D78662>. They are not intended for use with plain `int` types, but for use with `si_int` / `su_int` types (that are always 32-bit, unlike `int`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547



More information about the cfe-commits mailing list