diff options
| author | Björn Pettersson <bjorn.a.pettersson@ericsson.com> | 2024-05-02 22:49:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-02 22:49:39 +0200 |
| commit | 7298ae3b6d97777443aa89e38ab34b15482abfb3 (patch) | |
| tree | 03948abb4c0df5166477a32d981c928bfbcc0e04 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
| parent | b24aeef1cc4667f247ccf5d17913b1e1f2728d10 (diff) | |
[clang][CodeGen] Fix in codegen for __builtin_popcountg/ctzg/clzg (#90845)
Make sure that the result from the popcnt/ctlz/cttz intrinsics is
unsigned casted to int, rather than casted as a signed value, when
expanding the __builtin_popcountg/__builtin_ctzg/__builtin_clzg
builtins.
An example would be
unsigned _BitInt(1) x = ...;
int y = __builtin_popcountg(x);
which previously was incorrectly expanded to
%1 = call i1 @llvm.ctpop.i1(i1 %0)
%cast = sext i1 %1 to i32
Since the input type is generic for those "g" versions of the builtins
the intrinsic call may return a value for which the sign bit is set
(that could typically for BitInt of size 1 and 2). So we need to emit a
zext rather than a sext to avoid negative results.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions
