LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25458 - [Polly] Timeout during scop construction due to overly complex sets being formed
Summary: [Polly] Timeout during scop construction due to overly complex sets being formed
Status: RESOLVED FIXED
Alias: None
Product: Polly
Classification: Unclassified
Component: Optimizer (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Polly Development Mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-09 09:57 PST by Tobias Grosser
Modified: 2016-01-18 17:01 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Test case (10.06 KB, application/octet-stream)
2015-11-09 09:57 PST, Tobias Grosser
Details
Test case (10.36 KB, application/octet-stream)
2015-11-09 18:23 PST, Tobias Grosser
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Grosser 2015-11-09 09:57:43 PST
Created attachment 15253 [details]
Test case

Polly with 252451 times out when running polly-opt -polly-process-unprofitable timeout.ll

It seems that the sets we are creating during scop construction are becoming very complex. We could probably timeout on this, but my feeling is that at least for this test case we should be able to compute the scop represenation more efficiently?
Comment 1 Tobias Grosser 2015-11-09 10:13:28 PST
This test case is triggered in a couple of LNT failures I see.
Comment 2 Johannes Doerfert 2015-11-09 17:00:24 PST
I am not sure how we can compute something more efficiently here, sorry. The example test case simply has up to 2^10 many paths from the region entry to the exit, thus it is not suprising it takes a while to describe them all.

I would suggest to bail out, maybe if the number of parameters is too high or maybe if there are to many conditional branches in the same loop.
Comment 3 Tobias Grosser 2015-11-09 18:23:28 PST
Created attachment 15254 [details]
Test case

With the following patch and the attached test case I get a very simple set of conditions (precisely the ones I expect):

--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -1930,7 +1930,6 @@ void Scop::buildDomainsWithBranchConstraints(Region *R) {
     // executed at runtime.
     if (containsErrorBlock(RN, getRegion(), LI, DT)) {
       HasErrorBlock = true;
-      continue;
     }
 
     BasicBlock *BB = getRegionNodeBasicBlock(RN);


    	Stmt_bb15
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb15[] };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb15[] -> [0] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb15[] -> MemRef_A[0] };
    	Stmt_bb19
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb19[] : tmp17 <= -1 or tmp17 >= 1 };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb19[] -> [1] : tmp17 <= -1 or tmp17 >= 1 };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb19[] -> MemRef_A[0] };
    	Stmt_bb24
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb24[] };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb24[] -> [2] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb24[] -> MemRef_A[0] };
    	Stmt_bb29
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb29[] : tmp27 = 3 };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb29[] -> [3] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb29[] -> MemRef_A[0] };
    	Stmt_bb34
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb34[] };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb34[] -> [4] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb34[] -> MemRef_A[0] };
    	Stmt_bb39
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb39[] : tmp37 <= -1 or tmp37 >= 1 };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb39[] -> [5] : tmp37 <= -1 or tmp37 >= 1 };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb39[] -> MemRef_A[0] };
    	Stmt_bb43
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb43[] : (tmp37 <= -1 and tmp41 <= -1) or (tmp37 <= -1 and tmp41 >= 1) or (tmp37 >= 1 and tmp41 <= -1) or (tmp37 >= 1 and tmp41 >= 1) };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb43[] -> [6] : (tmp37 <= -1 and tmp41 <= -1) or (tmp37 <= -1 and tmp41 >= 1) or (tmp37 >= 1 and tmp41 <= -1) or (tmp37 >= 1 and tmp41 >= 1) };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb43[] -> MemRef_A[0] };
    	Stmt_bb49
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb49[] };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb49[] -> [7] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb49[] -> MemRef_A[0] };
    	Stmt_bb54
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb54[] : tmp52 <= -1 or tmp52 >= 1 };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb54[] -> [8] : tmp52 <= -1 or tmp52 >= 1 };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb54[] -> MemRef_A[0] };
    	Stmt_bb59
            Domain :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb59[] : tmp52 <= -1 or tmp52 >= 0 };
            Schedule :=
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb59[] -> [9] };
            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
                [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { Stmt_bb59[] -> MemRef_A[0] };


So the issue is that isl_set_coalesce() does not work due to us bailing out at error blocks. I think either we should not bail out for error blocks or we should try to propagate conditions forward from earlier basic blocks. Maybe the ones that dominate the block we look at, that are at themselves postdominated by the block we look at and that are at the same loop depth as the basic block we look at.

This test case also computes a rather complex assumed context (even after me commenting out the continue). My feeling is this assumed context could also be described with simpler sets.
Comment 4 Tobias Grosser 2015-11-11 10:27:04 PST
This has been addressed in r252750.
Comment 5 Tobias Grosser 2015-11-11 10:27:23 PST
This has been addressed in r252750.
Comment 6 Tanya Lattner 2016-01-18 17:01:14 PST
Move to Polly Product.