Skip to content

Commit ae2585d

Browse files
committed
Enable f16 and f128 on targets that were fixed in LLVM21
LLVM21 fixed the new float types on a number of targets: * SystemZ gained f16 support llvm/llvm-project#109164 * Hexagon now uses soft f16 to avoid recursion bugs llvm/llvm-project#130977 * Mips now correctly handles f128 (actually done in LLVM20) llvm/llvm-project#117525 * f128 is now correctly aligned when passing the stack on x86 llvm/llvm-project#138092 Thus, enable the types on relevant targets for LLVM > 21.0.0. NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.
1 parent dc0bae1 commit ae2585d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,24 +371,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
371371
let target_abi = sess.target.options.abi.as_ref();
372372
let target_pointer_width = sess.target.pointer_width;
373373
let version = get_version();
374+
let lt_20_1_1 = version < (20, 1, 1);
375+
let lt_21_0_0 = version < (21, 0, 0);
374376

375377
cfg.has_reliable_f16 = match (target_arch, target_os) {
376-
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
377-
("s390x", _) => false,
378-
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (now fixed)
378+
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
379379
("aarch64", _)
380-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
381-
&& version < (20, 1, 1) =>
380+
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
382381
{
383382
false
384383
}
385384
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
386385
("arm64ec", _) => false,
386+
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
387+
("s390x", _) if lt_21_0_0 => false,
387388
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
388389
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
389390
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
390391
("csky", _) => false,
391-
("hexagon", _) => false,
392+
("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21)
392393
("powerpc" | "powerpc64", _) => false,
393394
("sparc" | "sparc64", _) => false,
394395
("wasm32" | "wasm64", _) => false,
@@ -401,9 +402,10 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
401402
cfg.has_reliable_f128 = match (target_arch, target_os) {
402403
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
403404
("arm64ec", _) => false,
404-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
405-
("mips64" | "mips64r6", _) => false,
406-
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
405+
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
406+
("mips64" | "mips64r6", _) if lt_20_1_1 => false,
407+
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
408+
// but basic math still does not work.
407409
("nvptx64", _) => false,
408410
// Unsupported https://github.com/llvm/llvm-project/issues/121122
409411
("amdgpu", _) => false,
@@ -413,8 +415,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
413415
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
414416
("sparc", _) => false,
415417
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
416-
// not fail if our compiler-builtins is linked.
417-
("x86", _) => false,
418+
// not fail if our compiler-builtins is linked. (fixed in llvm21)
419+
("x86", _) if lt_21_0_0 => false,
418420
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
419421
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
420422
// There are no known problems on other platforms, so the only requirement is that symbols

0 commit comments

Comments
 (0)