Skip to content

Commit 127e0cd

Browse files
author
Eli Friedman
committedJun 14, 2017
Don't check side effects for functions outside of SCoP
In r304074 we introduce a patch to accept results from side effect free functions into SCEV modeling. This causes rejection of cases where the call is happening outside the SCoP. This patch checks if the call is outside the Region and treats the results as a parameter (SCEVType::PARAM) to the SCoP instead of returning SCEVType::INVALID. Patch by Sameer Abu Asal. llvm-svn: 305423
1 parent 5aa56d2 commit 127e0cd

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed
 

‎polly/lib/Support/SCEVValidator.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,12 @@ struct SCEVValidator
320320
ValidatorResult visitCallInstruction(Instruction *I, const SCEV *S) {
321321
assert(I->getOpcode() == Instruction::Call && "Call instruction expected");
322322

323-
auto Call = cast<CallInst>(I);
324-
325-
if (!isConstCall(Call))
326-
return ValidatorResult(SCEVType::INVALID, S);
323+
if (R->contains(I)) {
324+
auto Call = cast<CallInst>(I);
327325

326+
if (!isConstCall(Call))
327+
return ValidatorResult(SCEVType::INVALID, S);
328+
}
328329
return ValidatorResult(SCEVType::PARAM, S);
329330
}
330331

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; RUN: opt -polly-process-unprofitable -polly-scops -analyze < %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4+
5+
; CHECK: Region: %for.cond62---%for.cond
6+
; CHECK: p0: {0,+,1}<nuw><%for.cond>
7+
; CHECK-NEXT: p1: %param1
8+
; CHECK-NEXT: p2: %param2
9+
; CHECK-NEXT: Arrays {
10+
11+
define void @f(i8* %param1) {
12+
entry:
13+
br label %for.cond
14+
15+
for.cond:
16+
%hook = phi i8* [ %param1, %entry ], [ %add.ptr201, %cleanup ]
17+
br i1 undef, label %for.body, label %for.cond.cleanup
18+
19+
for.body:
20+
%param2 = call i32 @g()
21+
%add.ptr60 = getelementptr inbounds i8, i8* %hook, i32 %param2
22+
br label %for.cond62
23+
24+
for.cond62:
25+
%cmp64 = icmp ule i8* %add.ptr60, null
26+
br i1 %cmp64, label %for.cond62, label %cleanup
27+
28+
cleanup:
29+
%add.ptr201 = getelementptr inbounds i8, i8* %hook, i32 1
30+
br label %for.cond
31+
32+
for.cond.cleanup:
33+
ret void
34+
}
35+
36+
declare i32 @g()

0 commit comments

Comments
 (0)
Please sign in to comment.