Skip to content

Commit 9ceb765

Browse files
committed
Add fp cases. Autogenerate tests.
1 parent 8b27c18 commit 9ceb765

File tree

3 files changed

+47
-19
lines changed

3 files changed

+47
-19
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N) {
456456

457457
SDValue DAGTypeLegalizer::ScalarizeVecRes_ATOMIC_LOAD(AtomicSDNode *N) {
458458

459-
SDValue Result = DAG.getAtomic(ISD::ATOMIC_LOAD, SDLoc(N),
460-
N->getMemoryVT().getVectorElementType(),
461-
N->getValueType(0).getVectorElementType(),
462-
N->getChain(), N->getBasePtr(), N->getMemOperand());
459+
SDValue Result = DAG.getAtomic(
460+
ISD::ATOMIC_LOAD, SDLoc(N), N->getMemoryVT().getVectorElementType(),
461+
N->getValueType(0).getVectorElementType(), N->getChain(), N->getBasePtr(),
462+
N->getMemOperand());
463463

464464
// Legalize the chain result - switch anything that used the old chain to
465465
// use the new one.

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
25892589
setOperationAction(Op, MVT::f32, Promote);
25902590
}
25912591

2592+
setOperationAction(ISD::ATOMIC_LOAD, MVT::f32, Promote);
2593+
AddPromotedToType(ISD::ATOMIC_LOAD, MVT::f32, MVT::i32);
2594+
setOperationAction(ISD::ATOMIC_LOAD, MVT::f16, Promote);
2595+
AddPromotedToType(ISD::ATOMIC_LOAD, MVT::f16, MVT::i16);
2596+
25922597
// We have target-specific dag combine patterns for the following nodes:
25932598
setTargetDAGCombine({ISD::VECTOR_SHUFFLE,
25942599
ISD::SCALAR_TO_VECTOR,
Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
1-
; RUN: llc %s --mtriple=x86_64 -print-after=finalize-isel -disable-verify 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc %s --mtriple=x86_64 | FileCheck %s
23

3-
define i32 @atomic_scalar() {
4-
; CHECK: # *** IR Dump After Finalize ISel and expand pseudo-instructions (finalize-isel) ***:
5-
; CHECK-NEXT: # Machine code for function atomic_scalar: IsSSA, TracksLiveness
6-
; CHECK-NEXT: Frame Objects:
7-
; CHECK-NEXT: fi#0: size=4, align=4, at location [SP+8]
8-
; CHECK: bb.0 (%ir-block.0):
9-
; CHECK-NEXT: %0:gr32 = MOV32rm %stack.0, 1, $noreg, 0, $noreg :: (dereferenceable load acquire (s32) from %ir.1)
10-
; CHECK-NEXT: $eax = COPY %0:gr32
11-
; CHECK-NEXT: RET 0, $eax
12-
; CHECK: # End machine code for function atomic_scalar.
13-
%1 = alloca <1 x i32>
14-
%2 = load atomic <1 x i32>, ptr %1 acquire, align 4
15-
%3 = extractelement <1 x i32> %2, i32 0
16-
ret i32 %3
4+
define <1 x i32> @atomic_scalar_i32(ptr %x) {
5+
; CHECK-LABEL: atomic_scalar_i32:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: movl (%rdi), %eax
8+
; CHECK-NEXT: retq
9+
%ret = load atomic <1 x i32>, ptr %x acquire, align 4
10+
ret <1 x i32> %ret
11+
}
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
1740
}

0 commit comments

Comments
 (0)