<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 6, 2015 at 12:14 PM, Mark Schimmel <span dir="ltr"><<a href="mailto:Mark.Schimmel@synopsys.com" target="_blank">Mark.Schimmel@synopsys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">I cannot get Clang to add noalias via a cast operation. This code does not produce any warnings, and I believe it’s legal, but the restrict qualifier is lost. Am I incorrect about this code being legal? Any idea why the qualifier is stripped?
(It is a contrived example. You could imagine address checking and two separate loops.)</p></div></div></blockquote><div><br></div><div>We have no way to model this use of 'restrict' in our IR. Putting the 'restrict' on a function parameter should work. If you have an address checks and two separate loops, you could try factoring the 'noalias' loop out to a separate function.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><u></u></p>
<p class="MsoNormal">#define NOALIAS __restrict<u></u><u></u></p>
<p class="MsoNormal">//#define NOALIAS __attribute__((noalias))<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">void move(<u></u><u></u></p>
<p class="MsoNormal"> int* velocity_x, int* velocity_y, int* velocity_z,<u></u><u></u></p>
<p class="MsoNormal"> int* position_x,int* position_y,int* position_z,<u></u><u></u></p>
<p class="MsoNormal"> int* acceleration_x, int* acceleration_y, int* acceleration_z,<u></u><u></u></p>
<p class="MsoNormal"> int time_step, <u></u><u></u></p>
<p class="MsoNormal"> int count, <u></u><u></u></p>
<p class="MsoNormal"> int stride )<u></u><u></u></p>
<p class="MsoNormal">{<u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_acceleration_x = (int* NOALIAS)acceleration_x;</p></div></div></blockquote><div><br></div><div>The cast on the right-hand side does nothing; per C11 6.7.3/4, "The properties associated with qualified types are meaningful only for expressions that are lvalues."</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_velocity_x = (int* NOALIAS)velocity_x;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_position_x = (int* NOALIAS)position_x;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_acceleration_y = (int* NOALIAS)acceleration_y;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_velocity_y = (int* NOALIAS)velocity_y;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_position_y = (int* NOALIAS)position_y;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_acceleration_z = (int* NOALIAS)acceleration_z;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_velocity_z = (int* NOALIAS)velocity_z;<u></u><u></u></p>
<p class="MsoNormal"> int* NOALIAS r_position_z = (int* NOALIAS)position_z;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> for (int i=0;i<count*stride;i+=stride)<u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> r_velocity_x[i] += r_acceleration_x[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> r_velocity_y[i] += r_acceleration_y[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> r_velocity_z[i] += r_acceleration_z[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> r_position_x[i] += r_velocity_x[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> r_position_y[i] += r_velocity_y[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> r_position_z[i] += r_velocity_z[i] * time_step;<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>