Skip to content

Commit da3e8f6

Browse files
committed
[SelectionDAG][X86] Add floating point promotion.
When lowering atomic vector types with floats, selection can fail since this pattern is unsupported. To support this, floats can be casted to an integer type of the same size.
1 parent d9d4a1c commit da3e8f6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Diff for: llvm/lib/Target/X86/X86ISelLowering.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
25892589
setOperationAction(Op, MVT::f32, Promote);
25902590
}
25912591

2592+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f16, MVT::i16);
2593+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f32, MVT::i32);
2594+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f64, MVT::i64);
2595+
25922596
// We have target-specific dag combine patterns for the following nodes:
25932597
setTargetDAGCombine({ISD::VECTOR_SHUFFLE,
25942598
ISD::SCALAR_TO_VECTOR,

Diff for: llvm/test/CodeGen/X86/atomic-scalarization.ll

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ define <1 x i32> @atomic_scalar_i32(ptr %x) {
1010
ret <1 x i32> %ret
1111
}
1212

13+
define <1 x float> @atomic_scalar_float(ptr %x) {
14+
; CHECK-LABEL: atomic_scalar_float:
15+
; CHECK: # %bb.0:
16+
; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
17+
; CHECK-NEXT: retq
18+
%ret = load atomic <1 x float>, ptr %x acquire, align 4
19+
ret <1 x float> %ret
20+
}
21+
22+
define <1 x half> @atomic_scalar_half(ptr %x) {
23+
; CHECK-LABEL: atomic_scalar_half:
24+
; CHECK: # %bb.0:
25+
; CHECK-NEXT: movzwl (%rdi), %eax
26+
; CHECK-NEXT: pinsrw $0, %eax, %xmm0
27+
; CHECK-NEXT: retq
28+
%ret = load atomic <1 x half>, ptr %x acquire, align 4
29+
ret <1 x half> %ret
30+
}
31+
1332
define <1 x bfloat> @atomic_scalar_bfloat(ptr %x) {
1433
; CHECK-LABEL: atomic_scalar_bfloat:
1534
; CHECK: # %bb.0:

0 commit comments

Comments
 (0)