[LLVMdev] Parallel Loop Metadata
Hal Finkel
hfinkel at anl.gov
Sun Feb 17 13:15:09 PST 2013
----- Original Message -----
> From: "Andrew Trick" <atrick at apple.com>
> To: "Tobias Grosser" <tobias at grosser.es>
> Cc: "llvmdev at cs.uiuc.edu Dev" <llvmdev at cs.uiuc.edu>
> Sent: Sunday, February 17, 2013 2:32:25 PM
> Subject: Re: [LLVMdev] Parallel Loop Metadata
>
>
>
>
>
> On Feb 11, 2013, at 2:58 PM, Tobias Grosser < tobias at grosser.es >
> wrote:
>
>
> On 02/11/2013 10:31 PM, Nadav Rotem wrote:
>
>
> Now that we have a better understanding of the proposal for using
> per-instruction metadata, I think that we need to revisit the
> "single metedata" approach (Pekka's original suggestion).
>
> Following Andrew's comments we understood that Sebastian's proposal
> causes issues with inlining and unrolling. It seems we all agree
> that his proposal is not an option we can go with.
>
> Work is well on it's way now, and that's great. But just so people
> don't get the wrong impression from this thread. I'm not aware of
> any correctness issue with the "single metadata" approach. Inlining
> seems to work fine for me. Here's a hacky little example to see what
> I mean.
>
>
>
> define void @wrapper(i32* %arg) {
> %1 = call i32 @loop(i32* %arg)
> ret void
> }
>
>
> define i32 @loop(i32* %a) {
> entry:
> br label %loop
>
>
> loop: ; preds = %loop, %entry
> %p = phi i32* [%a,%entry], [%p1, %loop]
> %p1 = getelementptr i32* %p, i64 1
> %v = load i32* %p
> %cond = icmp eq i32 %v, 0
> br i1 %cond, label %loop, label %exit, !metadata !{i32* %p, metadata
> !0}
>
>
> exit: ; preds = %loop
> ret i32 %v
> }
>
>
> !0 = metadata !{metadata !"loop"}
>
>
> $ opt -inline -S <
>
>
>
> define void @wrapper(i32* %arg) {
> br label %loop.i
>
>
> loop.i: ; preds = %loop.i, %0
> %p.i = phi i32* [ %arg, %0 ], [ %p1.i, %loop.i ]
> %p1.i = getelementptr i32* %p.i, i64 1
> %v.i = load i32* %p.i
> %cond.i = icmp eq i32 %v.i, 0
> br i1 %cond.i, label %loop.i, label %loop.exit, !metadata !{i32*
> %p.i, metadata !0}
>
>
> loop.exit: ; preds = %loop.i
> ret void
> }
>
>
> !0 = metadata !{metadata !"loop"}
>
>
> ---
> Unrolling OTOH should be aware of and preserve any loop metadata.
If the unroller somehow differentiates the metadata coming from different loop iterations, then BBVectorize can use this information as well. Even better, we could make BasicAA understand that appropriately marked loads and stores from different iterations don't alias. Then the AA-based dependency breaker in the scheduler could also make use of the information. Thoughts?
-Hal
>
>
> -Andy
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list