[LLVMdev] parallel loop metadata simplification
Tobias Grosser
tobias at grosser.es
Sat Mar 2 10:44:20 PST 2013
On 03/01/2013 10:05 PM, Redmond, Paul wrote:
[...]
> I have discovered that you can provide a custom inserter to IRBuilder (who knew!). This has basically solved all my problems and allowed me to generate the proper metadata with minimal changes to clang codegen. Currently it adds the metadata to all loads and stores but I don't think this is a problem and can be refined later if necessary.
Great that you found a good solution. I have one example, which we may
want to have a look into:
Given the following input (test.c):
#pragma ivdep
for (long i = 0; i < 100; i++) {
long t = i + 2;
A[i] = t;
}
clang creates the following IR for the loop body:
%1 = load i64* %i, align 8
%add = add nsw i64 %1, 2
store i64 %add, i64* %t, align 8
%2 = load i64* %t, align 8
%3 = load i64* %i, align 8
%4 = load i64** %A.addr, align 8
%arrayidx = getelementptr inbounds i64* %4, i64 %3
store i64 %2, i64* %arrayidx, align 8
br label %for.inc
What are the implications of pragma ivdep on this code? My intuition
would be that 't' is iteration private and that using pragma ivdep for
this loop is correct. If the use of ivdep is correct, it seems necessary
to _not_ annotate the loads and stores from and to 't'. Only after 't'
is moved into a register, the loop is actually parallel on the IR level.
Cheers,
Tobi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 89 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130302/adb705ea/attachment.c>
More information about the llvm-dev
mailing list