<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 8/30/11 10:10 AM, Jimborean Alexandra wrote:
<blockquote
cite="mid:1314717028.62998.YahooMailNeo@web130215.mail.mud.yahoo.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div style="color: rgb(0, 0, 0); background-color: rgb(255, 255,
255); font-family: arial,helvetica,sans-serif; font-size: 10pt;">
<div>
<div>
<div>
<div>Hi,</div>
<div><br>
</div>
<div>I have a question regarding the GEP instruction. Is
it correct to consider that two GEP instructions compute
the same memory address if and only if all their
corresponding fields are equal? <br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
It's more complicated than that.<br>
<br>
First, all the operands of the GEP must be dynamically identical for
all executions. Second, the *type* of the pointer operands must be
identical.<br>
<br>
The first requirement means that you can't just statically look at
the SSA values and figure out if they're identical. Consider the
following psuedo-LLVM IR/C code example:<br>
<br>
while (x > 0) {<br>
y = gep p, 0, x<br>
}<br>
<br>
z = gep p, 0, x<br>
<br>
The two GEPs have identical, static SSA operands but won't compute
the same address because one is in a loop, and the other is not.
You have to tack on some additional requirements, like requiring
that y and z be in the same basic block. In short, you have to take
control-dependence into account somehow.<br>
<br>
The second requirement handles issues like the following:<br>
<br>
p = global int<br>
y = gep p, 0, x<br>
z = gep cast p to char *, 0, x<br>
<br>
Note that requirement 1 is fulfilled, but because p is an int * when
calculating y and a char * when calculating z, y and z will not be
the same values.<br>
<br>
-- John T.<br>
<br>
<br>
<blockquote
cite="mid:1314717028.62998.YahooMailNeo@web130215.mail.mud.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:10pt">
<div>
<div>
<div>
<div>
<br>
</div>
<div>For instance, for a two-dimensional array of
integers, can we have two GEP instructions that are
equal? <br>
</div>
<div><br>
</div>
<div> %arrayidx = getelementptr [10 x [30 x i32]]*
@main.B, i64 0, i64 0, i64 %tmp157</div>
<div><br>
%tmp = load i32* getelementptr inbounds ([10 x [30 x
i32]]* @main.B, i64 0, i64 3, i64 10), align 8</div>
<div><br>
</div>
<div>although their corresponding indices are different?
For instance if %tmp157 goes out of the bounds of the
line 0 and computes the address of the 10th element in
line 3.</div>
<div><br>
</div>
<div><br>
</div>
<div>Thank you,</div>
Alexandra</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>