<div><div dir="auto">The compiler constant folded it as an optimization. Was this compiled with optimization’s enabled?</div></div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, Aug 11, 2018 at 1:15 PM SANGEETA CHOWDHARY <<a href="mailto:sc1696@scarletmail.rutgers.edu">sc1696@scarletmail.rutgers.edu</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">I am sorry to not make my question clear. My question is how this value is calculated without having fadd and fsub in IR? </div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 11, 2018 at 4:06 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">Neither 1e16 or 1e16+1 can be accurately represented in a double. The largest integer than be accurately represented is 2^53. As the number gets larger floating sacrifices precision in the lower digits. Because of this 1e16 and 1e16+1 end up having the same representation. So the result of subtracting them is 0.0.</div></div><div><br><div class="gmail_quote"><div><div class="m_4287105992728451293h5"><div dir="ltr">On Sat, Aug 11, 2018 at 12:30 PM SANGEETA CHOWDHARY via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_4287105992728451293h5"><div dir="ltr"><font face="arial, helvetica, sans-serif">Hi,</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I have below code in C -</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>




<font face="arial, helvetica, sans-serif"><span></span> </font><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)">




<font face="arial, helvetica, sans-serif"><span></span> </font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">int</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"> main() {</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span></span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">double</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"> x,y;</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span>x = </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">1e16</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures">;</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span>y = (x + </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">1</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures">) - x;</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span>printf(</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"y:</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">%e\n</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures">, y);</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(205,121,35)"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s5" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span></span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures">return</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s5" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s5" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">;</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">}</font></span></p>


<font face="arial, helvetica, sans-serif"><br></font><p></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">llvm bitcode looks like this for this function -</font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif"><br></font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)">




<font face="arial, helvetica, sans-serif"><span></span> </font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">; Function Attrs: nounwind uwtable</font></span></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures">define dso_local i32 @main() local_unnamed_addr #</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"> {</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">entry:</font></span></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span>%</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">call</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"> = tail </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">call</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"> i32 (i8*, ...) @printf(i8* getelementptr inbounds ([</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">4</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"> x i8], [</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">4</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"> x i8]* @.str, i64 </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures">, i64 </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures">), double </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures">.000000e+</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">00</span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures">)</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><font face="arial, helvetica, sans-serif"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-Apple-converted-space">  </span>ret i32 </span><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span></font></p>
<p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><span class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">}</font></span></p>


<font face="arial, helvetica, sans-serif"><br></font><p></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">I am not able to understand how addition and subtraction are performed in this code. There is no fadd or fsub instruction. How llvm knows that result of y is 0? </font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">Is there any way to disable this in llvm?</font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif"><br></font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">Any help would be much appreciated.</font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif"><br></font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">Regards,</font></p><p class="m_4287105992728451293m_-3202128199626029255m_4289381388186567187gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><font face="arial, helvetica, sans-serif">Sangeeta</font></p></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><span class="m_4287105992728451293HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div></div><span class="m_4287105992728451293HOEnZb"><font color="#888888">-- <br><div dir="ltr" class="m_4287105992728451293m_-3202128199626029255gmail_signature" data-smartmail="gmail_signature">~Craig</div>
</font></span></blockquote></div><br></div>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div>