Skip to content

Commit 3e16b3d

Browse files
jgarzikclaude
andcommitted
cc: fix aarch64 float16 conversion using fmov instead of fcvt
emit_float_to_float() only recognized Float↔Double conversions in its needs_convert check, causing Float16↔Float/Double conversions to emit fmov (bit-copy) instead of fcvt (type conversion). The float16 bit pattern was zero-extended to 32 bits rather than properly converted, producing wrong values for all float16 arithmetic on aarch64. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 45ae13c commit 3e16b3d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cc/arch/aarch64/float.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ impl Aarch64CodeGen {
587587
let src_kind = insn.src_typ.map(|t| types.kind(t));
588588
let dst_kind = insn.typ.map(|t| types.kind(t));
589589
let needs_convert = match (src_kind, dst_kind) {
590+
(
591+
Some(TypeKind::Float16),
592+
Some(TypeKind::Float | TypeKind::Double | TypeKind::LongDouble),
593+
) => true,
594+
(
595+
Some(TypeKind::Float | TypeKind::Double | TypeKind::LongDouble),
596+
Some(TypeKind::Float16),
597+
) => true,
590598
(Some(TypeKind::Float), Some(TypeKind::Double | TypeKind::LongDouble)) => true,
591599
(Some(TypeKind::Double | TypeKind::LongDouble), Some(TypeKind::Float)) => true,
592600
// On aarch64, Double and LongDouble are the same, no conversion needed

0 commit comments

Comments
 (0)