You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[RISCV] Add support for STRICT_UINT_TO_FP and STRICT_SINT_TO_FP
This patch adds support for the missing STRICT_UINT_TO_FP and
STRICT_SINT_TO_FP for riscv and adds a test case for rv32 which was
previously crashing.
The code is mostly in line with how other strict_* nodes are handled
(e.g., getting op(1) instead of op(0) when it's a strict node, as op(0)
in a strict node is the entry token).
The only difference is the call to DAG.ReplaceAllUsesOfValueWith, to
replace any use of the STRICT_UINT_TO_FP and STRICT_SINT_TO_FP with the
new nodes we are creating here (e.g., strict_fp_to_fp16, strict_fp16_to_fp).
To understand why this is needed, let us consider the following program:
Result type 0 illegal: t4: i16 = truncate t3
SelectionDAG has 14 nodes:
t0: ch,glue = EntryToken
t2: f32,ch = CopyFromReg t0, Register:f32 %0
t3: i32 = bitcast t2
t4: i16 = truncate t3
t5: f16 = bitcast t4
t6: i32,ch = strict_fp_to_sint t0, t5
t11: i32,ch = strict_fp_to_sint t10:1, t10
t8: ch,glue = CopyToReg t6:1, Register:i32 $x10, t11
t13: i32 = and t3, Constant:i32<65535>
t10: f32,ch = strict_fp16_to_fp t0, t13
t9: ch = RISCVISD::RET_GLUE t8, Register:i32 $x10, t8:1
The chain of the original strict conversion was still being used elsewhere
in the function, meaning it (and its operands) were being kept alive.
This chain has a
i16 = truncate t3
which is an illegal return type in rv32 without zfhmin or zfh.
This was not a problem for the non-strict version of the nodes (i.e.,
UINT_TO_FP and SINT_TO_FP) as they don't have chain so the offending node
was being removed as dead code.
The DAG.ReplaceAllUsesOfValueWith replaces the usage of the STRICT_UINT_TO_FP
and STRICT_SINT_TO_FP with the new nodes that are being created, so the
truncate node is now also being removed as dead code.
0 commit comments