Skip to content

Commit 5e39c27

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 1fb4f56 commit 5e39c27

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-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

+29
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,32 @@ define <1 x i32> @atomic_scalar_i32(ptr %x) {
99
%ret = load atomic <1 x i32>, ptr %x acquire, align 4
1010
ret <1 x i32> %ret
1111
}
12+
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+
32+
define <1 x bfloat> @atomic_scalar_bfloat(ptr %x) {
33+
; CHECK-LABEL: atomic_scalar_bfloat:
34+
; CHECK: # %bb.0:
35+
; CHECK-NEXT: movzwl (%rdi), %eax
36+
; CHECK-NEXT: pinsrw $0, %eax, %xmm0
37+
; CHECK-NEXT: retq
38+
%ret = load atomic <1 x bfloat>, ptr %x acquire, align 4
39+
ret <1 x bfloat> %ret
40+
}

0 commit comments

Comments
 (0)