[PATCH] Templatify RegionInfo

Tobias Grosser tobias at grosser.es
Tue Jul 8 11:19:47 PDT 2014


On 08/07/2014 19:24, Nadav Rotem wrote:
>
>> On Jul 7, 2014, at 7:46 PM, Chandler Carruth <chandlerc at google.com> wrote:
>>
>> So, not really a comment on this specific patch, but how much more effort do we want to push into the region support in LLVM?
>>
>> Last time I tried to use the region infrastructure I found it was generally incomplete and no one was happy about relying on dominance frontiers. Are these still significant concerns? What is the path forward? I was easily able to rewrite my code in terms of DominatorTrees instead of regions, and it in some ways became simpler, so I'm not really sold lots of effort going into enhancing the support of regions in the optimizer.
>
> Dominance frontier is one way to compute Region info but the problem is that DF can grow quadratically.  There is a linear algorithm that is based on the Roman Chariots problem[1].
>
> [1] - http://dl.acm.org/citation.cfm?id=256217

Nadav is right. There is different work in this area. There is e.g. the 
classical paper:

"The program structure tree: Computing control regions in linear time"

To my understanding most algorithms only find what I call simple 
regions, which are regions that do have a single exit edge. Regions
that have multiple exit edges, but which can be merged into a single one 
are often ignored.

You can see the difference in many of the RegionInfo test cases (e.g
region.ll as attached):

opt -view-regions regions.ll -only-simple-regions

The solid squares are the simple regions, whereas the squares that are 
marked only with colored borders are the refined regions which the 
current RegionInfo can also detect.

Possibly interesting in this context is also this recent paper, which 
not only gives some interesting informations on the relation of 
dominance trees and sese regions, but also shows some problems with the 
original program structure paper (see section 5.1):

http://www1.cs.ucr.edu/faculty/philip/papers/journals/tecs/tecs12-ssi.pdf

Cheers,
Tobias




-------------- next part --------------
A non-text attachment was scrubbed...
Name: region.png
Type: image/png
Size: 60950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140708/74d22de2/attachment.png>
-------------- next part --------------
; ModuleID = '/tmp/test.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @cpu_matmul_kernel_good_1() {
r:
 br label %head

head:
 br label %br1

br1:
 br i1 undef, label %br1.l, label %br1.r

br1.l:
  br label %br1.fuse

br1.r:
  br label %br1.fuse

br1.fuse:
  br label %br2

br2:
 br i1 undef, label %br2.l, label %br2.r

br2.l:
  br label %br2.fuse

br2.r:
  br label %br2.fuse

br2.fuse:
  br label %back

back:
  br i1 undef, label %b, label %t

b:
  br label %head

t:
  ret void
}


More information about the llvm-commits mailing list