This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Enhance costmodel of FoldTwoEntryPHINode while consider branch misprediction
AbandonedPublic

Authored by lkail on Jan 21 2022, 12:54 AM.

Details

Summary

This is the alternative method based on SimplifyCFG to solve problem mentioned in https://reviews.llvm.org/D113872, i.e., consider code

loop:
...
if (cond) {
  // update max/min values
  // update indexes of max/min values
}

Currently simplifycfg transforms this snippet of code to

loop:
  select cond ...
  select cond ...

This is not always profitable since we have redundant computations of select's operands. Branch is not always profitable either since branch may incur high mispredict penalty. This patch uses the cost estimation by @lebedev.ri mentioned in https://reviews.llvm.org/D113872 to enhance costmodel.

Diff Detail

Event Timeline

lkail created this revision.Jan 21 2022, 12:54 AM
lkail requested review of this revision.Jan 21 2022, 12:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2022, 12:54 AM
lkail edited the summary of this revision. (Show Details)Jan 21 2022, 1:09 AM

I have finished the rough cut of the patch with complete rewrite of FoldTwoEntryPHINode(),
i think it may be good to deal with that first, but i'm not sure whom i can talk into reviewing it,
simplifycfg doesn't really have a stable set of contributors/reviewers.

I have finished the rough cut of the patch with complete rewrite of FoldTwoEntryPHINode(),
i think it may be good to deal with that first

Ok, that sounds good.

lkail abandoned this revision.Mar 10 2022, 8:47 PM

Since https://reviews.llvm.org/D120230 is posted, abandon effort on simplifycfg.

Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2022, 8:47 PM