[llvm] [X86][GISel] Fix crash on bitcasting i16 <-> half with gisel enabled. (PR #168456)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 01:16:07 PST 2025
e-kud wrote:
I tend to consider that GlobalISel needs to emit quite similar code to SDAG on such small examples.
```
Optimized legalized selection DAG: %bb.0 'test_i16_to_half:entry'
SelectionDAG has 9 nodes:
t0: ch,glue = EntryToken
t2: i32,ch = CopyFromReg t0, Register:i32 %0
t3: i16 = truncate t2
t4: f16 = bitcast t3
t7: ch,glue = CopyToReg t0, Register:f16 $xmm0, t4
t8: ch = X86ISD::RET_GLUE t7, TargetConstant:i32<0>, Register:f16 $xmm0, t7:1
```
```
# *** IR Dump Before InstructionSelect (instruction-select) ***:
# Machine code for function test_i16_to_half: IsSSA, TracksLiveness, Legalized, RegBankSelected
Function Live Ins: $edi
bb.1.entry:
liveins: $edi
%1:gpr(s32) = COPY $edi
%0:gpr(s16) = G_TRUNC %1:gpr(s32)
$xmm0 = COPY %0:gpr(s16)
RET 0, implicit $xmm0
```
I'd think that the problem is in GlobalISel that bitcast hasn't been inserted by IRTranslator. But probably for natural insertion of this bitcast #155107 is required.
https://github.com/llvm/llvm-project/pull/168456
More information about the llvm-commits
mailing list