This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Swap guards estimation sequence. NFC
ClosedPublic

Authored by dfukalov on Jan 17 2020, 8:28 AM.

Details

Summary

Loop unroll spends a lot of time in SCEVs processing in case when a function
contains hundreds of simple 'for' loops with a quite complex arrays indexes like

for (int i = 0; i < 8; ++i) {
  for (int j = 0; j < 32; ++j) {
    C[j*8+i] = B[j*32+i+128] + A[i*64+128];
  }
}
for (int i = 0; i < 8; ++i) {
  for (int j = 0; j < 8; ++j) {
    for (int k = 0; k < 32; ++k) {
      D[k*64+i*8+j] = D[k*64+i*8+j] + E[i+16] * C[k*8+j+256];
    }
  }
}

The patch improves loop unroll speed since isLoopBackedgeGuardedByCond takes
much less time than isLoopEntryGuardedByCond in the edge case.

Diff Detail

Event Timeline

dfukalov created this revision.Jan 17 2020, 8:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2020, 8:28 AM
fhahn added a subscriber: fhahn.Jan 17 2020, 9:28 AM
sanjoy accepted this revision.Jan 19 2020, 1:54 PM

lgtm, although it would be nice to independently check if isLoopEntryGuardedByCond can be sped up.

Please also add a comment stating that the order and short circuit behavior is intentional.

This revision is now accepted and ready to land.Jan 19 2020, 1:54 PM
This revision was automatically updated to reflect the committed changes.