diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-04 10:49:43 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-04 10:49:43 +0200 |
| commit | 21bd67796ed2a51c3ef6ea285f4737628e304567 (patch) | |
| tree | c1447f1111300bfdc5cbc14440e5c494876d125e /compiler/rustc_codegen_gcc/src/intrinsic/mod.rs | |
| parent | e1b9081e699065badfc1a9419ec9566e5c8615c4 (diff) | |
| parent | 482e8540a1b757ed7bccc2041c5400f051fdb01e (diff) | |
| download | rust-21bd67796ed2a51c3ef6ea285f4737628e304567.tar.gz rust-21bd67796ed2a51c3ef6ea285f4737628e304567.zip | |
Merge commit '482e8540a1b757ed7bccc2041c5400f051fdb01e' into subtree-update_cg_gcc_2025-08-04
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/intrinsic/mod.rs')
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/intrinsic/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 0753ac1aeb8..eb0a5336a1f 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -925,10 +925,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { // TODO(antoyo): use width? let arg_type = arg.get_type(); let result_type = self.u32_type; + let arg = if arg_type.is_signed(self.cx) { + let new_type = arg_type.to_unsigned(self.cx); + self.gcc_int_cast(arg, new_type) + } else { + arg + }; + let arg_type = arg.get_type(); let count_leading_zeroes = // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here // instead of using is_uint(). - if arg_type.is_uint(self.cx) { + if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { "__builtin_clz" } else if arg_type.is_ulong(self.cx) { |
