Index: polly/trunk/lib/Analysis/ScopDetection.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopDetection.cpp +++ polly/trunk/lib/Analysis/ScopDetection.cpp @@ -659,23 +659,7 @@ return true; } - if (I->mayHaveSideEffects()) - return false; - - if (isa(I)) - return false; - - // When Val is a Phi node, it is likely not invariant. We do not check whether - // Phi nodes are actually invariant, we assume that Phi nodes are usually not - // invariant. - if (isa(*I)) - return false; - - for (const Use &Operand : I->operands()) - if (!isInvariant(*Operand, Reg, Ctx)) - return false; - - return true; + return false; } /// Remove smax of smax(0, size) expressions from a SCEV expression and Index: polly/trunk/test/Isl/CodeGen/invariant_verify_function_failed.ll =================================================================== --- polly/trunk/test/Isl/CodeGen/invariant_verify_function_failed.ll +++ polly/trunk/test/Isl/CodeGen/invariant_verify_function_failed.ll @@ -1,4 +1,4 @@ -; RUN: opt %loadPolly -S -polly-codegen -polly-invariant-load-hoisting=true %s | FileCheck %s +; RUN: opt %loadPolly -polly-detect -polly-codegen -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s ; ; This crashed at some point as the pointer returned by the call ; to @__errno_location is invariant and defined in the SCoP but not @@ -7,7 +7,10 @@ ; to hoist %tmp. We don't try to hoist %tmp anymore but this test still ; checks that this passes to code generation and produces valid code. ; -; CHECK: polly.start +; This SCoP is currently rejected because %call9 is not considered a valid +; base pointer. +; +; CHECK-NOT: Valid Region for Scop ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: polly/trunk/test/ScopDetect/base_pointer.ll =================================================================== --- polly/trunk/test/ScopDetect/base_pointer.ll +++ polly/trunk/test/ScopDetect/base_pointer.ll @@ -179,9 +179,10 @@ for.i: %indvar.i = phi i64 [ %indvar.i.next, %for.i.inc ], [ 0, %entry ] -; To get an instruction inside a region, we use a function without side -; effects on which SCEV blocks, but for which it is still clear that the -; return value remains invariant throughout the whole loop. +; A function return value, even with readnone nounwind attributes, is not +; considered a valid base pointer because it can return a pointer that aliases +; with something else (e.g. %A or a global) or return a different pointer at +; every call (e.g. malloc) %ptr = call float* @getNextBasePtr(float* %A) br label %S1 @@ -201,7 +202,7 @@ } ; CHECK-LABEL: base_pointer_is_inst_inside_invariant_1 -; CHECK: Valid Region for Scop: for.i => exit +; CHECK-NOT: Valid Region for Scop declare float* @getNextBasePtr2(float*) readnone nounwind @@ -231,7 +232,7 @@ } ; CHECK-LABEL: base_pointer_is_inst_inside_invariant_2 -; CHECK: Valid Region for Scop: for.i => exit +; CHECK-NOT: Valid Region for Scop declare float* @getNextBasePtr3(float*, i64) readnone nounwind Index: polly/trunk/test/ScopDetect/base_pointer_is_inst_inside_invariant_1___%for.i---%exit.jscop =================================================================== --- polly/trunk/test/ScopDetect/base_pointer_is_inst_inside_invariant_1___%for.i---%exit.jscop +++ polly/trunk/test/ScopDetect/base_pointer_is_inst_inside_invariant_1___%for.i---%exit.jscop @@ -0,0 +1,24 @@ +{ + "arrays" : [ + { + "name" : "MemRef_ptr", + "sizes" : [ "*" ], + "type" : "float" + } + ], + "context" : "[n] -> { : -9223372036854775808 <= n <= 9223372036854775807 }", + "name" : "%for.i---%exit", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_ptr[i0+1] }" + } + ], + "domain" : "[n] -> { Stmt_S1[i0] : 0 <= i0 < n }", + "name" : "Stmt_S1", + "schedule" : "[n] -> { Stmt_S1[i0] -> [i0] }" + } + ] +} Index: polly/trunk/test/ScopDetect/base_pointer_setNewAccessRelation.ll =================================================================== --- polly/trunk/test/ScopDetect/base_pointer_setNewAccessRelation.ll +++ polly/trunk/test/ScopDetect/base_pointer_setNewAccessRelation.ll @@ -0,0 +1,37 @@ +; RUN: opt %loadPolly -disable-basicaa -polly-detect -polly-import-jscop -polly-import-jscop-dir=%S -polly-codegen -analyze < %s | FileCheck %s +; +; Polly codegen used to generate invalid code (referring to %ptr from the +; original region) when regeneration of the access function is necessary. +; The SCoP is now rejected as a whole because %ptr is not considered a valid +; base pointer. +; +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + +declare float* @getNextBasePtr(float*) readnone nounwind + +define void @base_pointer_is_inst_inside_invariant_1(i64 %n, float* %A) { +entry: + br label %for.i + +for.i: + %indvar.i = phi i64 [ %indvar.i.next, %for.i.inc ], [ 0, %entry ] + br label %S1 + +S1: + %ptr = call float* @getNextBasePtr(float* %A) + %conv = sitofp i64 %indvar.i to float + %arrayidx5 = getelementptr float, float* %ptr, i64 %indvar.i + store float %conv, float* %arrayidx5, align 4 + br label %for.i.inc + +for.i.inc: + %indvar.i.next = add i64 %indvar.i, 1 + %exitcond.i = icmp ne i64 %indvar.i.next, %n + br i1 %exitcond.i, label %for.i, label %exit + +exit: + ret void +} + + +; CHECK-NOT: Valid Region for Scop