Skip to content

Commit b336c25

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 4d0be71 commit b336c25

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,31 @@ define <1 x ptr> @atomic_vec1_ptr_align8(ptr %x) nounwind {
136136
%ret = load atomic <1 x ptr>, ptr %x acquire, align 8
137137
ret <1 x ptr> %ret
138138
}
139+
140+
define <1 x half> @atomic_vec1_half(ptr %x) {
141+
; CHECK3-LABEL: atomic_vec1_half:
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_half:
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 half>, ptr %x acquire, align 4
156+
ret <1 x half> %ret
157+
}
158+
159+
define <1 x float> @atomic_vec1_float(ptr %x) {
160+
; CHECK-LABEL: atomic_vec1_float:
161+
; CHECK: ## %bb.0:
162+
; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
163+
; CHECK-NEXT: retq
164+
%ret = load atomic <1 x float>, ptr %x acquire, align 4
165+
ret <1 x float> %ret
166+
}

0 commit comments

Comments
 (0)