[PATCH] SimplifyIndVar: Forget loops that are made infinite
Arnold Schwaighofer
aschwaighofer at apple.com
Wed May 8 15:51:05 PDT 2013
After talking to Andy, I don’t think this is the right approach.
We cannot assume if there is back-edge taken count there will be a certain loop structure.
On May 8, 2013, at 4:31 PM, Arnold Schwaighofer <aschwaighofer at apple.com> wrote:
> We can transform loops into infinite ones. When this happens we should "forget"
> the SCEV for such loops.
>
> Later transformations might depend on the SCEVs to be correct. For example, the
> backedge taken count. The loop vectorizer - rightly in my opinion - assumes that
> if there is a backedge take count - there should be an induction variable.
>
> Fixes PR15926.
>
>
> long long a;
> volatile int x;
> void fn1 () {
> for (a = 0; a >= 0; ++a)
> x = 0;
> }
>
> We (indvars) used to transform this from:
>
>
> define void @fn1() {
> entry:
> store i64 0, i64* @a, align 8
> br label %for.body
>
> for.body:
> %inc1 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
> store volatile i32 0, i32* @x, align 4
> %inc = add nsw i64 %inc1, 1
> %cmp = icmp sgt i64 %inc1, -2
> br i1 %cmp, label %for.body, label %for.end
>
> for.end:
> %inc.lcssa = phi i64 [ %inc, %for.body ]
> store i64 %inc.lcssa, i64* @a, align 8
> ret void
> }
>
> to:
>
> define void @fn1() {
> entry:
> store i64 0, i64* @a, align 8, !tbaa !0
> br label %for.body
>
> for.body: ; preds = %entry, %for.body
> store volatile i32 0, i32* @x, align 4, !tbaa !3
> br i1 true, label %for.body, label %for.end
>
> for.end: ; preds = %for.body
> store i64 -9223372036854775807, i64* @a, align 8, !tbaa !0
> ret void
> }
>
>
> But kept the original SCEVs alive.
>
>
>
> <0001-SimplifyIndVar-Forget-loops-that-are-made-infinite.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list