Skip to content

Commit 70bb5b9

Browse files
committed
[X86] Manage atomic load of fp -> int promotion in DAG
When lowering atomic <1 x T> 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. commit-id:f9d761c5
1 parent 7263545 commit 70bb5b9

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
25952595
setOperationAction(Op, MVT::f32, Promote);
25962596
}
25972597

2598+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f16, MVT::i16);
2599+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f32, MVT::i32);
2600+
setOperationPromotedToType(ISD::ATOMIC_LOAD, MVT::f64, MVT::i64);
2601+
25982602
// We have target-specific dag combine patterns for the following nodes:
25992603
setTargetDAGCombine({ISD::VECTOR_SHUFFLE,
26002604
ISD::SCALAR_TO_VECTOR,

llvm/test/CodeGen/X86/atomic-load-store.ll

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,50 @@ define <1 x ptr addrspace(270)> @atomic_vec1_ptr270(ptr %x) {
108108
%ret = load atomic <1 x ptr addrspace(270)>, ptr %x acquire, align 4
109109
ret <1 x ptr addrspace(270)> %ret
110110
}
111+
112+
define <1 x half> @atomic_vec1_half(ptr %x) {
113+
; CHECK3-LABEL: atomic_vec1_half:
114+
; CHECK3: ## %bb.0:
115+
; CHECK3-NEXT: movzwl (%rdi), %eax
116+
; CHECK3-NEXT: pinsrw $0, %eax, %xmm0
117+
; CHECK3-NEXT: retq
118+
;
119+
; CHECK0-LABEL: atomic_vec1_half:
120+
; CHECK0: ## %bb.0:
121+
; CHECK0-NEXT: movw (%rdi), %cx
122+
; CHECK0-NEXT: ## implicit-def: $eax
123+
; CHECK0-NEXT: movw %cx, %ax
124+
; CHECK0-NEXT: ## implicit-def: $xmm0
125+
; CHECK0-NEXT: pinsrw $0, %eax, %xmm0
126+
; CHECK0-NEXT: retq
127+
%ret = load atomic <1 x half>, ptr %x acquire, align 4
128+
ret <1 x half> %ret
129+
}
130+
131+
define <1 x float> @atomic_vec1_float(ptr %x) {
132+
; CHECK-LABEL: atomic_vec1_float:
133+
; CHECK: ## %bb.0:
134+
; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
135+
; CHECK-NEXT: retq
136+
%ret = load atomic <1 x float>, ptr %x acquire, align 4
137+
ret <1 x float> %ret
138+
}
139+
140+
define <1 x bfloat> @atomic_vec1_bfloat(ptr %x) {
141+
; CHECK3-LABEL: atomic_vec1_bfloat:
142+
; CHECK3: ## %bb.0:
143+
; CHECK3-NEXT: movzwl (%rdi), %eax
144+
; CHECK3-NEXT: pinsrw $0, %eax, %xmm0
145+
; CHECK3-NEXT: retq
146+
;
147+
; CHECK0-LABEL: atomic_vec1_bfloat:
148+
; CHECK0: ## %bb.0:
149+
; CHECK0-NEXT: movw (%rdi), %cx
150+
; CHECK0-NEXT: ## implicit-def: $eax
151+
; CHECK0-NEXT: movw %cx, %ax
152+
; CHECK0-NEXT: ## implicit-def: $xmm0
153+
; CHECK0-NEXT: pinsrw $0, %eax, %xmm0
154+
; CHECK0-NEXT: retq
155+
%ret = load atomic <1 x bfloat>, ptr %x acquire, align 4
156+
ret <1 x bfloat> %ret
157+
}

0 commit comments

Comments
 (0)