llvm.org GIT mirror llvm / 161e3a8
R600: Fix extloads from i8 / i16 to i64. This appears to only be working for global loads. Private and local break for other reasons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203135 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 5 years ago
5 changed file(s) with 106 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
700700 ZEXTLOAD,
701701 LAST_LOADEXT_TYPE
702702 };
703
704 NodeType getExtForLoadExtType(LoadExtType);
703705
704706 //===--------------------------------------------------------------------===//
705707 /// ISD::CondCode enum - These are ordered carefully to make the bitfields
228228 return false;
229229
230230 return true;
231 }
232
233 ISD::NodeType ISD::getExtForLoadExtType(ISD::LoadExtType ExtType) {
234 switch (ExtType) {
235 case ISD::EXTLOAD:
236 return ISD::ANY_EXTEND;
237 case ISD::SEXTLOAD:
238 return ISD::SIGN_EXTEND;
239 case ISD::ZEXTLOAD:
240 return ISD::ZERO_EXTEND;
241 default:
242 break;
243 }
244
245 llvm_unreachable("Invalid LoadExtType");
231246 }
232247
233248 /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
691691 SDLoc DL(Op);
692692 LoadSDNode *Load = cast(Op);
693693 ISD::LoadExtType ExtType = Load->getExtensionType();
694 EVT VT = Op.getValueType();
695 EVT MemVT = Load->getMemoryVT();
696
697 if (ExtType != ISD::NON_EXTLOAD && !VT.isVector() && VT.getSizeInBits() > 32) {
698 // We can do the extload to 32-bits, and then need to separately extend to
699 // 64-bits.
700
701 SDValue ExtLoad32 = DAG.getExtLoad(ExtType, DL, MVT::i32,
702 Load->getChain(),
703 Load->getBasePtr(),
704 MemVT,
705 Load->getMemOperand());
706 return DAG.getNode(ISD::getExtForLoadExtType(ExtType), DL, VT, ExtLoad32);
707 }
694708
695709 // Lower loads constant address space global variable loads
696710 if (Load->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS &&
710724 return SDValue();
711725
712726
713 EVT VT = Op.getValueType();
714 EVT MemVT = Load->getMemoryVT();
715727 unsigned Mask = 0;
716728 if (Load->getMemoryVT() == MVT::i8) {
717729 Mask = 0xff;
127127 setLoadExtAction(ISD::SEXTLOAD, MVT::i32, Expand);
128128 setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Custom);
129129 setLoadExtAction(ISD::SEXTLOAD, MVT::i16, Custom);
130 setLoadExtAction(ISD::ZEXTLOAD, MVT::i32, Expand);
131 setLoadExtAction(ISD::ZEXTLOAD, MVT::i8, Custom);
132 setLoadExtAction(ISD::ZEXTLOAD, MVT::i16, Custom);
130133 setLoadExtAction(ISD::SEXTLOAD, MVT::v8i16, Expand);
131134 setLoadExtAction(ISD::SEXTLOAD, MVT::v16i16, Expand);
132135
None ; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG %s
0 ; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
1 ; RUN: llc -march=r600 -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
12
2 ; EG-LABEL: @anyext_load_i8:
3 ; FUNC-LABEL: @anyext_load_i8:
34 ; EG: AND_INT
45 ; EG: 255
56 define void @anyext_load_i8(i8 addrspace(1)* nocapture noalias %out, i8 addrspace(1)* nocapture noalias %src) nounwind {
1112 ret void
1213 }
1314
14 ; EG-LABEL: @anyext_load_i16:
15 ; FUNC-LABEL: @anyext_load_i16:
1516 ; EG: AND_INT
1617 ; EG: AND_INT
1718 ; EG-DAG: 65535
2526 ret void
2627 }
2728
28 ; EG-LABEL: @anyext_load_lds_i8:
29 ; FUNC-LABEL: @anyext_load_lds_i8:
2930 ; EG: AND_INT
3031 ; EG: 255
3132 define void @anyext_load_lds_i8(i8 addrspace(3)* nocapture noalias %out, i8 addrspace(3)* nocapture noalias %src) nounwind {
3738 ret void
3839 }
3940
40 ; EG-LABEL: @anyext_load_lds_i16:
41 ; FUNC-LABEL: @anyext_load_lds_i16:
4142 ; EG: AND_INT
4243 ; EG: AND_INT
4344 ; EG-DAG: 65535
5051 store <2 x i16> %x, <2 x i16> addrspace(3)* %castOut, align 1
5152 ret void
5253 }
54
55 ; FUNC-LABEL: @sextload_global_i8_to_i64
56 ; SI: BUFFER_LOAD_SBYTE [[LOAD:v[0-9]+]],
57 ; SI: V_ASHRREV_I32_e32 v{{[0-9]+}}, 31, [[LOAD]]
58 ; SI: BUFFER_STORE_DWORDX2
59 define void @sextload_global_i8_to_i64(i64 addrspace(1)* %out, i8 addrspace(1)* %in) nounwind {
60 %a = load i8 addrspace(1)* %in, align 8
61 %ext = sext i8 %a to i64
62 store i64 %ext, i64 addrspace(1)* %out, align 8
63 ret void
64 }
65
66 ; FUNC-LABEL: @sextload_global_i16_to_i64
67 ; SI: BUFFER_LOAD_SSHORT [[LOAD:v[0-9]+]],
68 ; SI: V_ASHRREV_I32_e32 v{{[0-9]+}}, 31, [[LOAD]]
69 ; SI: BUFFER_STORE_DWORDX2
70 define void @sextload_global_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
71 %a = load i16 addrspace(1)* %in, align 8
72 %ext = sext i16 %a to i64
73 store i64 %ext, i64 addrspace(1)* %out, align 8
74 ret void
75 }
76
77 ; FUNC-LABEL: @sextload_global_i32_to_i64
78 ; SI: BUFFER_LOAD_DWORD [[LOAD:v[0-9]+]],
79 ; SI: V_ASHRREV_I32_e32 v{{[0-9]+}}, 31, [[LOAD]]
80 ; SI: BUFFER_STORE_DWORDX2
81 define void @sextload_global_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
82 %a = load i32 addrspace(1)* %in, align 8
83 %ext = sext i32 %a to i64
84 store i64 %ext, i64 addrspace(1)* %out, align 8
85 ret void
86 }
87
88 ; FUNC-LABEL: @zextload_global_i8_to_i64
89 ; SI: BUFFER_LOAD_UBYTE [[LOAD:v[0-9]+]],
90 ; SI: V_MOV_B32_e32 {{v[0-9]+}}, 0
91 ; SI: BUFFER_STORE_DWORDX2
92 define void @zextload_global_i8_to_i64(i64 addrspace(1)* %out, i8 addrspace(1)* %in) nounwind {
93 %a = load i8 addrspace(1)* %in, align 8
94 %ext = zext i8 %a to i64
95 store i64 %ext, i64 addrspace(1)* %out, align 8
96 ret void
97 }
98
99 ; FUNC-LABEL: @zextload_global_i16_to_i64
100 ; SI: BUFFER_LOAD_USHORT [[LOAD:v[0-9]+]],
101 ; SI: V_MOV_B32_e32 {{v[0-9]+}}, 0
102 ; SI: BUFFER_STORE_DWORDX2
103 define void @zextload_global_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
104 %a = load i16 addrspace(1)* %in, align 8
105 %ext = zext i16 %a to i64
106 store i64 %ext, i64 addrspace(1)* %out, align 8
107 ret void
108 }
109
110 ; FUNC-LABEL: @zextload_global_i32_to_i64
111 ; SI: BUFFER_LOAD_DWORD [[LOAD:v[0-9]+]],
112 ; SI: V_MOV_B32_e32 {{v[0-9]+}}, 0
113 ; SI: BUFFER_STORE_DWORDX2
114 define void @zextload_global_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
115 %a = load i32 addrspace(1)* %in, align 8
116 %ext = zext i32 %a to i64
117 store i64 %ext, i64 addrspace(1)* %out, align 8
118 ret void
119 }