[LLVMdev] Number of Bytes a GetElementPtr .
ether zhhb
etherzhhb at gmail.com
Mon Apr 19 20:51:50 PDT 2010
hi,
You could get it from the ScalarEvolution analysis(target data must
available):
c code:
int f(int a[][4], int i, int j) {
return a[i][j];
}
llvm ir:
define i32 @f([4 x i32]* nocapture %a, i32 %i, i32 %j) nounwind readonly {
entry:
%0 = sext i32 %i to i64 ; <i64> [#uses=1]
%1 = sext i32 %j to i64 ; <i64> [#uses=1]
%2 = getelementptr inbounds [4 x i32]* %a, i64 %0, i64 %1 ; <i32*>
[#uses=1]
%3 = load i32* %2, align 4 ; <i32> [#uses=1]
ret i32 %3
}
SCEV expression of %2:
%2 = getelementptr inbounds [4 x i32]* %a, i64 %0, i64 %1 ; <i32*> [#uses=1]
--> ((4 * (sext i32 %j to i64)) + (16 * (sext i32 %i to i64)) + %a)
--best regards
ether
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100420/d1ae4ab0/attachment.html>
More information about the llvm-dev
mailing list