<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi, Jon,</p>
<p>We don't simplify pointer quality based on AA because an AA
noalias result is not strong enough to imply pointer inequality.
It certainly seems possible that our existing logic could be
improved. I suspect you'll want to look at
ConstantFoldCompareInstruction, and perhaps specifically
evaluateICmpRelation, in lib/IR/ConstantFold.cpp. Patches welcome.<br>
</p>
<p> -Hal<br>
</p>
<div class="moz-cite-prefix">On 06/20/2017 06:33 PM, Jon
Chesterfield via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CAOUYtQCo0FnGY0NBSRqF9Q1vFxHVMFw2rC+cP0z6tUP=a7-kcw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>basicaa with pointers to distinct globals.<br>
<br>
static const int x = 4;<br>
static const int y = 5;<br>
static const double z = 6.0;<br>
<br>
int types_match(void)<br>
{<br>
return (char*)&x == (char*)&y;<br>
}<br>
<br>
int types_differ(void)<br>
{<br>
return (char*)&x == (char*)&z;<br>
}<br>
<br>
</div>
I'd like both tests to resolve to 'false' at the IR
level, but the mixed type one doesn't at O3:<br>
<br>
target triple = "x86_64-unknown-linux-gnu"<br>
@x = internal constant i32 4, align 4<br>
@z = internal constant double 6.000000e+00, align 8<br>
<br>
define i32 @types_match() {<br>
ret i32 0<br>
}<br>
<br>
define i32 @types_differ() {<br>
ret i32 zext (i1 icmp eq (double* bitcast (i32* @x to
double*), double* @z) to i32)<br>
}<br>
<br>
</div>
Discovered in code which uses a static variable's address
as a failure indicator. Imagine a function which returns 0
for out of memory, &some_var for bad arguments,
pointer to something useful otherwise. The static variable
happens to have a different type because flexible array
members are involved with length 0 for the failure
indicator and length !=0 in general.<br>
<br>
</div>
I consider this a failure in the alias analysis - would a
patch be welcome, or is this intended behaviour that I've
missed the point of?<br>
<br>
</div>
Cheers<br>
<br>
</div>
Jon<br>
</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>