Index: lib/Analysis/ScopBuilder.cpp =================================================================== --- lib/Analysis/ScopBuilder.cpp +++ lib/Analysis/ScopBuilder.cpp @@ -642,7 +642,8 @@ std::vector Instructions; for (Instruction &Inst : *I->getNodeAs()) { Loop *L = LI.getLoopFor(Inst.getParent()); - if (!isa(&Inst) && !canSynthesize(&Inst, *scop, &SE, L)) + if (!isa(&Inst) && !isIgnoredIntrinsic(&Inst) && + !canSynthesize(&Inst, *scop, &SE, L)) Instructions.push_back(&Inst); } Loop *SurroundingLoop = LI.getLoopFor(I->getNodeAs()); Index: test/ScopInfo/intrinsics_misc.ll =================================================================== --- /dev/null +++ test/ScopInfo/intrinsics_misc.ll @@ -0,0 +1,90 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-print-instructions -S < %s | FileCheck %s +; +; Verify that we remove the ignored intrinsics from the instruction list. +; +; CHECK-NOT: call void @llvm.donothing +; +; int A[1024], B[1024]; +; void jd() { +; for (int i = 0; i < 1024; i++) { +; for (int j = i; j < 1024; j++) +; B[i] += B[j]; +; A[i] = B[i]; +; } +; } +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +@A = global [1024 x i32] zeroinitializer, align 16 +@B = global [1024 x i32] zeroinitializer, align 16 + +; Function Attrs: noinline nounwind uwtable +define void @_Z2jdv() #0 { +entry: + %i = alloca i32, align 4 + %j = alloca i32, align 4 + store i32 0, i32* %i, align 4 + br label %for.cond + + for.cond: ; preds = %for.inc10, %entry + %0 = load i32, i32* %i, align 4 + %cmp = icmp slt i32 %0, 1024 + br i1 %cmp, label %for.body, label %for.end12 + + for.body: ; preds = %for.cond + %1 = load i32, i32* %i, align 4 + store i32 %1, i32* %j, align 4 + br label %for.cond1 + + for.cond1: ; preds = %for.inc, %for.body + %2 = load i32, i32* %j, align 4 + %cmp2 = icmp slt i32 %2, 1024 + br i1 %cmp2, label %for.body3, label %for.end + + for.body3: ; preds = %for.cond1 + %3 = load i32, i32* %j, align 4 + %idxprom = sext i32 %3 to i64 + %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* @B, i64 0, i64 %idxprom + %4 = load i32, i32* %arrayidx, align 4 + %5 = load i32, i32* %i, align 4 + %idxprom4 = sext i32 %5 to i64 + %arrayidx5 = getelementptr inbounds [1024 x i32], [1024 x i32]* @B, i64 0, i64 %idxprom4 + call void @llvm.donothing() + %6 = load i32, i32* %arrayidx5, align 4 + %add = add nsw i32 %6, %4 + store i32 %add, i32* %arrayidx5, align 4 + br label %for.inc + + for.inc: ; preds = %for.body3 + %7 = load i32, i32* %j, align 4 + %inc = add nsw i32 %7, 1 + store i32 %inc, i32* %j, align 4 + br label %for.cond1 + + for.end: ; preds = %for.cond1 + %8 = load i32, i32* %i, align 4 + %idxprom6 = sext i32 %8 to i64 + %arrayidx7 = getelementptr inbounds [1024 x i32], [1024 x i32]* @B, i64 0, i64 %idxprom6 + %9 = load i32, i32* %arrayidx7, align 4 + %10 = load i32, i32* %i, align 4 + %idxprom8 = sext i32 %10 to i64 + %arrayidx9 = getelementptr inbounds [1024 x i32], [1024 x i32]* @A, i64 0, i64 %idxprom8 + store i32 %9, i32* %arrayidx9, align 4 + br label %for.inc10 + + for.inc10: ; preds = %for.end + %11 = load i32, i32* %i, align 4 + %inc11 = add nsw i32 %11, 1 + store i32 %inc11, i32* %i, align 4 + br label %for.cond + + for.end12: ; preds = %for.cond + ret void +} + +; Function Attrs: nounwind +declare void @llvm.donothing() #1 + +attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +