<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>At a high level, EarlyCSE should be intersecting the metadata of instructions that it combines. If it doesn't, and also doesn't drop the metadata, that seems like a bug, regardless of anything else.<br>
</p>
<div class="moz-cite-prefix">On 1/22/20 9:30 AM, Jeroen Dobbelaere wrote:<br>
</div>
<blockquote type="cite" cite="mid:DM6PR12MB3996EC88EC4DA01C18C29A83B50C0@DM6PR12MB3996.namprd12.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.pre
        {mso-style-name:pre;}
p.first, li.first, div.first
        {mso-style-name:first;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.std
        {mso-style-name:std;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi Neil, Hall,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- as far as 'C' is concerned, this is input code is valid, as the pointers are not used to modify objects.<o:p></o:p></p>
<p class="MsoNormal">- as far as 'llvm LangRef' is concerned, this is <b><span style="color:red">invalid</span></b> code:
<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">   noalias</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:.5in">
This indicates that objects accessed via pointer values <a href="http://www.llvm.org/docs/LangRef.html#pointeraliasing" moz-do-not-send="true">
based</a> on the argument or return value are not also accessed, during the execution of the function, via pointer values not
<i>based</i> on the argument or return value. The attribute on a return value also has additional semantics described below. The caller shares the responsibility with the callee for ensuring that these requirements are met. For further details, please see the
 discussion of the NoAlias response in <a href="http://www.llvm.org/docs/AliasAnalysis.html#must-may-or-no" moz-do-not-send="true">
alias analysis</a>.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- clang can proof that after inlining, *a and *b are identical, so it can omit one of the loads.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- I think that both versions are acceptable (for C):<o:p></o:p></p>
<p class="MsoNormal">-- (A) dropping the noalias information will result in less optimization opportunities<o:p></o:p></p>
<p class="MsoNormal">-- (B) preferring the load with the noalias annotation can allow more reorderings and a better schedule.<o:p></o:p></p>
<p class="MsoNormal">  (especially when there would be a 'store' in the context where the restrict is valid; aka in 'called').<o:p></o:p></p>
<p class="MsoNormal">  <o:p></o:p></p>
<p class="MsoNormal">My preference would go to (B) as that opens up more optimization opportunities.</p>
</div>
</blockquote>
<p><br>
</p>
<p>I'm concerned that this isn't sound. So, imagine if I had something like this:</p>
int * restrict r = a;<br>
...<br>
int x = noaliasing ? *r : *a;<br>
<p>then we need the aliasing load to retain its dependencies relative to other things in the block. If we combine them into one load, it needs to be the aliasing one.<br>
</p>
<p>Thanks again,</p>
<p>Hal<br>
</p>
<blockquote type="cite" cite="mid:DM6PR12MB3996EC88EC4DA01C18C29A83B50C0@DM6PR12MB3996.namprd12.prod.outlook.com">
<div class="WordSection1">
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Notes:<o:p></o:p></p>
<p class="MsoNormal">- clang with 'full restrict' has similar behavior as the standard clang.
<o:p></o:p></p>
<p class="MsoNormal">- the collapsing seems to be happening in 'EarlyCSE'.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Greetings,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Jeroen Dobbelaere<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in
          0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1
              1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <a class="moz-txt-link-rfc2396E" href="mailto:llvm-dev-bounces@lists.llvm.org">
<llvm-dev-bounces@lists.llvm.org></a> <b>On Behalf Of </b>Neil Henning via llvm-dev<br>
<b>Sent:</b> Wednesday, January 22, 2020 14:02<br>
<b>To:</b> llvm-dev <a class="moz-txt-link-rfc2396E" href="mailto:llvm-dev@lists.llvm.org">
<llvm-dev@lists.llvm.org></a><br>
<b>Subject:</b> [llvm-dev] Inlining + CSE + restrict pointers == funtimes<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">So I've been narrowing down a very fun issue in our Burst compiler stack with respect to noalias support, and I've managed to basically boil this down to the following failure (see
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__godbolt.org_z_-2DmdjPV&d=DwMFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=ELyOnT0WepII6UnFk-OSzxlGOXXSfAvOLT6E8iPwwJk&m=aOzDT5OLTyJR4khihblFI8hsLwAXqccKhWgUehiRiR4&s=XWkvlt9v4v-iBS_HFjm8-b3FQVTO3UCsgWPECbAPkX4&e=" moz-do-not-send="true">
https://godbolt.org/z/-mdjPV</a>):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">int</span><span style="color:black"> called(</span><span style="color:blue">int</span><span style="color:black">* __restrict__ a,
</span><span style="color:blue">int</span><span style="color:black">* b, </span><span style="color:blue">int</span><span style="color:black">* c) {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">return</span><span style="color:black"> *a + *b + *c;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">int</span><span style="color:black"> foo(</span><span style="color:blue">int</span><span style="color:black"> * x,
</span><span style="color:blue">int</span><span style="color:black"> * y) {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">return</span><span style="color:black"> *x + *y + called(x, x, y);<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">int</span><span style="color:black"> bar(</span><span style="color:blue">int</span><span style="color:black"> * x,
</span><span style="color:blue">int</span><span style="color:black"> * y) {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">return</span><span style="color:black"> called(x, x, y) + *x + *y;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">Which becomes:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">define</span><span style="color:black">
</span><span style="color:teal">dso_local</span><span style="color:black"> </span>
<span style="color:teal">i32</span><span style="color:black"> </span><span style="color:teal">@called</span><span style="color:black">(</span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:teal">noalias</span><span style="color:black"> </span><span style="color:teal">nocapture</span><span style="color:black">
</span><span style="color:teal">readonly</span><span style="color:black"> </span>
<span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">i32</span><span style="color:black">* </span><span style="color:teal">nocapture</span><span style="color:black">
</span><span style="color:teal">readonly</span><span style="color:black"> </span>
<span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">,
</span><span style="color:teal">i32</span><span style="color:black">* </span><span style="color:teal">nocapture</span><span style="color:black">
</span><span style="color:teal">readonly</span><span style="color:black"> </span>
<span style="color:#CD3131">%</span><span style="color:#09885A">2</span><span style="color:black">)
</span><span style="color:teal">local_unnamed_addr</span><span style="color:black">
</span><span style="color:#09885A">#0</span><span style="color:black"> !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">7</span><span style="color:black"> {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%4</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">19</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%5</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">24</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%6</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">nsw</span><span style="color:black"> </span><span style="color:teal">i32</span><span style="color:black">
</span><span style="color:#CD3131">%</span><span style="color:#09885A">5</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">25</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%7</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">2</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">26</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%8</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">nsw</span><span style="color:black"> </span><span style="color:teal">i32</span><span style="color:black">
</span><span style="color:#CD3131">%</span><span style="color:#09885A">6</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">7</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">27</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">ret</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">8</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">28</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">define</span><span style="color:black">
</span><span style="color:teal">dso_local</span><span style="color:black"> </span>
<span style="color:teal">i32</span><span style="color:black"> </span><span style="color:teal">@foo</span><span style="color:black">(</span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:teal">nocapture</span><span style="color:black"> </span>
<span style="color:teal">readonly</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">i32</span><span style="color:black">* </span><span style="color:teal">nocapture</span><span style="color:black">
</span><span style="color:teal">readonly</span><span style="color:black"> </span>
<span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">)
</span><span style="color:teal">local_unnamed_addr</span><span style="color:black">
</span><span style="color:#09885A">#0</span><span style="color:black"> !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">29</span><span style="color:black"> {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%3</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">36</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%4</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">37</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%5</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">4</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">3</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%6</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">shl</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">5</span><span style="color:black">,
</span><span style="color:#09885A">1</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%7</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">6</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">3</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">38</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">ret</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">7</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">39</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">define</span><span style="color:black">
</span><span style="color:teal">dso_local</span><span style="color:black"> </span>
<span style="color:teal">i32</span><span style="color:black"> </span><span style="color:teal">@bar</span><span style="color:black">(</span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:teal">nocapture</span><span style="color:black"> </span>
<span style="color:teal">readonly</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">i32</span><span style="color:black">* </span><span style="color:teal">nocapture</span><span style="color:black">
</span><span style="color:teal">readonly</span><span style="color:black"> </span>
<span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">)
</span><span style="color:teal">local_unnamed_addr</span><span style="color:black">
</span><span style="color:#09885A">#0</span><span style="color:black"> !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">40</span><span style="color:black"> {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%3</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">0</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">47</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black">, !</span><span style="color:teal">alias.scope</span><span style="color:black"> !</span><span style="color:#09885A">48</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%4</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">load</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black">, </span><span style="color:teal">i32</span><span style="color:black">*
</span><span style="color:#CD3131">%</span><span style="color:#09885A">1</span><span style="color:black">,
</span><span style="color:teal">align</span><span style="color:black"> </span><span style="color:#09885A">4</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">51</span><span style="color:black">,
 !</span><span style="color:teal">tbaa</span><span style="color:black"> !</span><span style="color:#09885A">20</span><span style="color:black">, !</span><span style="color:teal">noalias</span><span style="color:black"> !</span><span style="color:#09885A">48</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%5</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">4</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">3</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%6</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">shl</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">5</span><span style="color:black">,
</span><span style="color:#09885A">1</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:#CD3131">%7</span><span style="color:black">
</span><span style="color:#CD3131">=</span><span style="color:black"> </span><span style="color:blue">add</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">6</span><span style="color:black">,
</span><span style="color:#CD3131">%</span><span style="color:#09885A">3</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">52</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:blue">ret</span><span style="color:black">
</span><span style="color:teal">i32</span><span style="color:black"> </span><span style="color:#CD3131">%</span><span style="color:#09885A">7</span><span style="color:black">, !</span><span style="color:teal">dbg</span><span style="color:black"> !</span><span style="color:#09885A">53</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#FFFFFE"><span style="color:black">}<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The issue is that CSE just looks at two loads from the same location and goes 'hey I can combine them!' but it doesn't take into account whether either load has extra aliasing information or not. So in foo it has turned a noalias pointer
 into an aliasing one, but in bar it has turned an aliasing pointer into a non-aliasing one.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm not sure what the C spec says (if anything) about this, but for us we'd like the behaviour to be defined.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Does anyone have any opinions on solving this before I drop a patch?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Should we perhaps make the behaviour to choose (alias over non-alias, or vice versa) controllable via a hidden CSE option?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">What should we do in the presence of two conflicting sets of noalias information?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Sidenote: I'm aware of the 'full restrict' patch that has been circulated, but irrespective of whether that lands or not we'd still like to have some defined behaviour for the above case.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-Neil.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<table class="MsoNormalTable" style="width:100.0%;border-collapse:collapse" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="padding:0in 0in 15.0pt 0in" valign="top">
<table class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0" cellpadding="0" border="0" align="left">
<tbody>
<tr>
<td style="width:48.0pt;padding:0in 0in
                                  0in 0in" width="64" valign="top">
<p class="MsoNormal" style="line-height:18.0pt"><span style="font-size:12.5pt;border:solid
                                      windowtext 1.0pt;padding:0in"><img style="width:.6666in;height:.6666in" id="_x0000_i1025" src="cid:part4.A9C76568.1F07734B@anl.gov" alt="Image removed by sender." class="" width="64" height="64" border="0"></span><span style="font-size:12.5pt"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="padding:0in 0in 0in 0in" valign="top">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><b><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black">Neil Henning<o:p></o:p></span></b></p>
</div>
</td>
</tr>
<tr>
<td style="padding:0in 0in 0in 0in" valign="top">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:black">Senior Software Engineer Compiler<o:p></o:p></span></p>
</div>
</td>
</tr>
<tr>
<td style="padding:0in 0in 0in 0in" valign="top">
<div>
<p class="MsoNormal" style="line-height:11.25pt"><span style="font-size:9.0pt;font-family:"Arial",sans-serif;color:black"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__unity.com&d=DwMFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=ELyOnT0WepII6UnFk-OSzxlGOXXSfAvOLT6E8iPwwJk&m=aOzDT5OLTyJR4khihblFI8hsLwAXqccKhWgUehiRiR4&s=MOPIlmrVJiQcmTppCNARdwomJe8vQtGH_huTf2-b8qU&e=" target="_blank" moz-do-not-send="true">unity.com</a><o:p></o:p></span></p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>