<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 05/30/2018 06:04 AM, Siddharth Bhat
via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPipc=0Hf3izBpjEzbMOjQfTRFeTka+8sbmKP9D90+ueU5LJKg@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
You can run SCEV which will see through bitcasts and GEPs, so it
should give an expression of the form (base + offset) on the
pointer of the load.</blockquote>
<br>
Specifically, you can use ScalarEvolution to subtract the expression
for the base descriptor from the expression for the loaded pointer
and see if the result is a SCEVConstant.<br>
<br>
Also, you might find GetPointerBaseWithConstantOffset (in
ValueTracking.h) useful.<br>
<br>
-Hal<br>
<br>
<blockquote type="cite"
cite="mid:CAPipc=0Hf3izBpjEzbMOjQfTRFeTka+8sbmKP9D90+ueU5LJKg@mail.gmail.com">
<div><br>
</div>
<div>Cheers</div>
<div>siddharth</div>
<div><br>
<div class="gmail_quote">
<div dir="ltr">On Wed 30 May, 2018, 16:30 Venkataramanan Kumar
via llvm-dev, <<a href="mailto:llvm-dev@lists.llvm.org"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,
<div><br>
</div>
<div>Below is the snippet of LLVM IR code generated by
Flang </div>
<div><br>
</div>
<div>---snip--</div>
<div> %3 = getelementptr i64, i64* %"a$sd", i64 11, !dbg
!16<br>
</div>
<div>
<div> %4 = bitcast i64* %3 to i32*, !dbg !16</div>
<div> %5 = load i32, i32* %4, align 4, !dbg !16, !tbaa
!22</div>
</div>
<div>---snip--</div>
<div><br>
</div>
<div>My requirement is for any such LoadInst (example:
%5), I want to check if its base GEP (i.e. %3) loads at
particular offset (11) from its corresponding arrays
descriptor structure (a$sd).</div>
<div><br>
</div>
<div>
<div
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">is
there any API in LLVM to check this? or I need to
write my own?</div>
<div
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br>
</div>
<div
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">regards,</div>
<div
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">Venkat.</div>
<div
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br
class="m_6311213337484395444gmail-Apple-interchange-newline">
</div>
</div>
<div><br>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
</div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">Sending this from my phone, please excuse any
typos!</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>