Changeset 3917 in CLRX
- Timestamp:
- Mar 21, 2018, 8:50:59 PM (5 weeks ago)
- Location:
- CLRadeonExtender/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CLRadeonExtender/trunk/amdasm/AsmRegAlloc.cpp
r3916 r3917 944 944 stackVarMap = *cached; 945 945 pfStartIndex = it->second.second+1; 946 947 // apply missing calls at end of the cached 948 const CodeBlock& cblock = codeBlocks[it->second.first]; 949 for (const NextBlock& next: cblock.nexts) 950 if (next.isCall) 951 { 952 std::cout << " applycall (cache): " << it->second.first << ": " << 953 next.block << std::endl; 954 const LastSSAIdMap& regVarMap = 955 routineMap.find(next.block)->second.lastSSAIdMap; 956 for (const auto& sentry: regVarMap) 957 stackVarMap[sentry.first] = sentry.second; 958 } 946 959 } 947 960 } … … 1240 1253 std::cout << " " << v; 1241 1254 std::cout << std::endl; 1255 } 1256 } 1257 1258 static void reduceSSAIdsForCalls(FlowStackEntry& entry, 1259 const std::vector<CodeBlock>& codeBlocks, 1260 RetSSAIdMap& retSSAIdMap, std::unordered_map<size_t, RoutineData>& routineMap, 1261 SSAReplacesMap& ssaReplacesMap) 1262 { 1263 if (retSSAIdMap.empty()) 1264 return; 1265 LastSSAIdMap rbwSSAIdMap; 1266 std::unordered_set<AsmSingleVReg> reduced; 1267 std::unordered_set<AsmSingleVReg> changed; 1268 const CodeBlock& cblock = codeBlocks[entry.blockIndex]; 1269 // collect rbw SSAIds 1270 for (const NextBlock next: cblock.nexts) 1271 if (next.isCall) 1272 { 1273 auto it = routineMap.find(next.block); // must find 1274 for (const auto& rentry: it->second.rbwSSAIdMap) 1275 rbwSSAIdMap.insertSSAId(rentry.first,rentry.second); 1276 1277 } 1278 for (const NextBlock next: cblock.nexts) 1279 if (next.isCall) 1280 { 1281 auto it = routineMap.find(next.block); // must find 1282 // add changed 1283 for (const auto& lentry: it->second.lastSSAIdMap) 1284 if (rbwSSAIdMap.find(lentry.first) == rbwSSAIdMap.end()) 1285 changed.insert(lentry.first); 1286 } 1287 1288 // reduce SSAIds 1289 for (const auto& rentry: retSSAIdMap) 1290 { 1291 auto ssaIdsIt = rbwSSAIdMap.find(rentry.first); 1292 if (ssaIdsIt != rbwSSAIdMap.end()) 1293 { 1294 const VectorSet<size_t>& ssaIds = ssaIdsIt->second; 1295 const VectorSet<size_t>& rssaIds = rentry.second.ssaIds; 1296 Array<size_t> outSSAIds(ssaIds.size() + rssaIds.size()); 1297 std::copy(rssaIds.begin(), rssaIds.end(), outSSAIds.begin()); 1298 std::copy(ssaIds.begin(), ssaIds.end(), outSSAIds.begin()+rssaIds.size()); 1299 1300 std::sort(outSSAIds.begin(), outSSAIds.end()); 1301 outSSAIds.resize(std::unique(outSSAIds.begin(), outSSAIds.end()) - 1302 outSSAIds.begin()); 1303 size_t minSSAId = outSSAIds.front(); 1304 if (outSSAIds.size() >= 2) 1305 { 1306 for (auto sit = outSSAIds.begin()+1; sit != outSSAIds.end(); ++sit) 1307 insertReplace(ssaReplacesMap, rentry.first, *sit, minSSAId); 1308 1309 std::cout << "calls retssa ssaid: " << rentry.first.regVar << ":" << 1310 rentry.first.index << std::endl; 1311 } 1312 1313 for (size_t rblock: rentry.second.routines) 1314 routineMap.find(rblock)->second.lastSSAIdMap[rentry.first] = 1315 VectorSet<size_t>({ minSSAId }); 1316 reduced.insert(rentry.first); 1317 } 1318 } 1319 for (const AsmSingleVReg& vreg: reduced) 1320 retSSAIdMap.erase(vreg); 1321 reduced.clear(); 1322 1323 for (const AsmSingleVReg& vreg: changed) 1324 { 1325 auto rit = retSSAIdMap.find(vreg); 1326 if (rit != retSSAIdMap.end()) 1327 { 1328 // if modified 1329 // put before removing to revert for other ways after calls 1330 auto res = entry.prevRetSSAIdSets.insert(*rit); 1331 if (res.second) 1332 res.first->second = rit->second; 1333 // just remove, if some change without read before 1334 retSSAIdMap.erase(rit); 1335 } 1242 1336 } 1243 1337 } … … 1949 2043 if (entry.nextIndex!=0) // if back from calls (just return from calls) 1950 2044 { 2045 reduceSSAIdsForCalls(entry, codeBlocks, retSSAIdMap, routineMap, 2046 ssaReplacesMap); 1951 2047 // 1952 2048 for (const NextBlock& next: cblock.nexts) -
CLRadeonExtender/trunk/tests/amdasm/AsmRegAllocCase2.cpp
r3915 r3917 659 659 { // SSA replaces 660 660 { { "sa", 2 }, { { 3, 2 }, { 4, 1 } } }, 661 { { "sa", 5 }, { { 3, 1 }, { 5, 2 }, { 6, 1 } } } 661 { { "sa", 3 }, { { 3, 1 } } }, 662 { { "sa", 5 }, { { 3, 1 }, { 5, 2 }, { 6, 1 } } }, 662 663 }, 663 664 true, "" … … 783 784 { // SSA replaces 784 785 { { "sa", 2 }, { { 3, 2 }, { 4, 1 } } }, 786 { { "sa", 3 }, { { 3, 1 } } }, 785 787 { { "sa", 5 }, { { 4, 2 }, { 5, 1 } } } 786 788 }, … … 929 931 { { "sa", 2 }, { { 4, 2 } } }, 930 932 { { "sa", 3 }, { { 4, 2 } } }, 931 { { "sa", 4 }, { { 4, 2 } } },933 { { "sa", 4 }, { { 4, 3 }, { 4, 2 } } }, 932 934 { { "sa", 5 }, { { 5, 2 } } } 933 935 }, … … 1178 1180 { }, 1179 1181 { 1180 { { "sa", 7 }, SSAInfo( 2, 6, 6, 6, 1, true) }1182 { { "sa", 7 }, SSAInfo(1, 6, 6, 6, 1, true) } 1181 1183 }, false, false, true }, 1182 1184 { // block 8 - routine … … 1239 1241 { { "sa", 5 }, { { 5, 1 }, { 6, 1 } } }, 1240 1242 { { "sa", 6 }, { { 2, 1 }, { 3, 1 }, { 4, 1 }, { 7, 1 } } }, 1241 { { "sa", 7 }, { { 3, 2 }, { 4, 2 }, { 2, 1 } } } 1243 //{ { "sa", 7 }, { { 3, 2 }, { 4, 2 }, { 2, 1 } } } 1244 { { "sa", 7 }, { { 2, 1 }, { 3, 1 }, { 4, 1 } } } 1242 1245 }, 1243 1246 true, "" -
CLRadeonExtender/trunk/tests/amdasm/AsmRegAllocCase3.cpp
r3916 r3917 163 163 { 164 164 { { "sa", 0 }, SSAInfo(0, SIZE_MAX, 1, SIZE_MAX, 0, true) }, 165 { { "sa", 2 }, SSAInfo( 2, 6, 6, 6, 1, true) },165 { { "sa", 2 }, SSAInfo(1, 6, 6, 6, 1, true) }, 166 166 { { "sa", 3 }, SSAInfo(1, 7, 7, 7, 1, true) }, 167 167 { { "sa", 4 }, SSAInfo(1, 9, 9, 9, 1, true) }, … … 382 382 }, 383 383 { // SSA replaces 384 /*{ { "sa", 2 }, { { 3, 2 }, { 4, 2 }, { 5, 2 }, { 5, 1 }, { 4, 1 } } },384 { { "sa", 2 }, { { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 1 } } }, 385 385 { { "sa", 3 }, { { 2, 1 }, { 4, 1 }, { 5, 1 }, { 6, 1 } } }, 386 386 { { "sa", 4 }, { { 2, 1 }, { 4, 3 }, { 3, 1 }, { 4, 1 }, 387 { 5, 1 }, { 6, 1 } } },388 { { "sa", 5 }, { { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 1 } } } */387 { 5, 1 }, { 6, 1 }, { 8, 3 }, { 7, 3 } } }, 388 { { "sa", 5 }, { { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 1 } } } 389 389 }, 390 390 true, ""
Note: See TracChangeset
for help on using the changeset viewer.