@@ -989,8 +989,7 @@ void VariableReuseAnalysis::visitExtractElementInst(ExtractElementInst& I)
989
989
// be merged into part of other value.)
990
990
if (m_HasBecomeNoopInsts.count (EEI) ||
991
991
m_DeSSA->isNoopAliaser (EEI) ||
992
- isOrCoalescedWithArg (EEI) ||
993
- isOrCoalescedWithArg (vecVal) ||
992
+ !isSingleVecAliasee (vecVal) ||
994
993
(m_WIA && m_WIA->whichDepend (EEI) != m_WIA->whichDepend (vecVal))) {
995
994
return ;
996
995
}
@@ -1002,7 +1001,7 @@ void VariableReuseAnalysis::visitExtractElementInst(ExtractElementInst& I)
1002
1001
// skip it for now (implementation choice).
1003
1002
// Note that payload-coalescing does not use node value yet.
1004
1003
if (hasBeenPayloadCoalesced (EEI) ||
1005
- isVecAliaser (EEI_nv)) {
1004
+ ! isSingleVecAliaser (EEI_nv)) {
1006
1005
return ;
1007
1006
}
1008
1007
@@ -1450,8 +1449,19 @@ void VariableReuseAnalysis::addVecAlias(
1450
1449
aliaserSV->Aliasers .clear ();
1451
1450
}
1452
1451
1453
- // Finally, add aliaserSV into root's Aliaser vector
1452
+ // Finally, add aliaserSV into root's Aliaser vector and
1453
+ // update aliaser to its root map if aliaser's not isolated.
1454
1454
rootSV->Aliasers .push_back (aliaserSV);
1455
+ // aliaser
1456
+ Value* rv0 = m_DeSSA ? m_DeSSA->getRootValue (Aliaser) : nullptr ;
1457
+ if (rv0) {
1458
+ m_root2AliasMap[rv0] = Aliaser;
1459
+ }
1460
+ // aliasee
1461
+ Value* rv1 = m_DeSSA ? m_DeSSA->getRootValue (Aliasee) : nullptr ;
1462
+ if (rv1) {
1463
+ m_root2AliasMap[rv1] = Aliasee;
1464
+ }
1455
1465
}
1456
1466
1457
1467
SSubVecDesc* VariableReuseAnalysis::getOrCreateSubVecDesc (Value* V)
@@ -1463,15 +1473,43 @@ SSubVecDesc* VariableReuseAnalysis::getOrCreateSubVecDesc(Value* V)
1463
1473
return m_aliasMap[V];
1464
1474
}
1465
1475
1466
- bool VariableReuseAnalysis::isVecAliaser (llvm::Value* V) const
1476
+ bool VariableReuseAnalysis::isVecAliased (Value* V) const
1477
+ {
1478
+ if (m_aliasMap.count (V) > 0 ) {
1479
+ return true ;
1480
+ }
1481
+
1482
+ Value* rv = m_DeSSA ? m_DeSSA->getRootValue (V) : nullptr ;
1483
+ return (rv && m_root2AliasMap.count (rv) > 0 );
1484
+ }
1485
+
1486
+ bool VariableReuseAnalysis::isSingleVecAliaser (llvm::Value* V) const
1467
1487
{
1468
1488
auto II = m_aliasMap.find (V);
1469
- if (II == m_aliasMap.end ())
1470
- return false ;
1471
- SSubVecDesc* SV = II->second ;
1472
- return SV->Aliaser != SV->BaseVector ;
1489
+ if (II != m_aliasMap.end ()) {
1490
+ SSubVecDesc* SV = II->second ;
1491
+ if (SV->Aliaser != SV->BaseVector )
1492
+ return false ;
1493
+ }
1494
+
1495
+ return isSingleVecAliasee (V);
1496
+ }
1497
+
1498
+ bool VariableReuseAnalysis::isSingleVecAliasee (llvm::Value* V) const
1499
+ {
1500
+ // Check if any value of its dessa CC has been aliased already.
1501
+ Value* rv = m_DeSSA ? m_DeSSA->getRootValue (V) : nullptr ;
1502
+ if (rv) {
1503
+ auto II = m_root2AliasMap.find (rv);
1504
+ if (II != m_root2AliasMap.end ()) {
1505
+ Value* aV = II->second ;
1506
+ return V == aV;
1507
+ }
1508
+ }
1509
+ return true ;
1473
1510
}
1474
1511
1512
+
1475
1513
// A chain of IEIs is used to define a vector. If all elements of this vector
1476
1514
// are inserted via this chain IEI that has a constant index, populate AllIEIs.
1477
1515
// input: FirstIEI (first IEI, usually with index = 0)
0 commit comments