<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 29, 2017, at 5:48 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
</p>
<div class="moz-cite-prefix">On 06/29/2017 07:26 PM, Peter Lawrence
wrote:<br class="">
</div>
<blockquote cite="mid:56CF6936-E6DC-445C-AAEA-FB51E4FB89D5@sbcglobal.net" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252" class="">
<div class="">Hal,</div>
<div class=""> Mehdi points out I mis-quoted you, I apologize
sincerely.</div>
<div class=""><br class="">
</div>
Mehdi,
<div class=""> Thank you for forcing me to go back and
re-read what Hal wrote,</div>
<div class="">I could have sworn Hal and I were in agreement at
the time I wrote you,</div>
<div class="">Must have been asleep at the wheel, not enough sleep
last night</div>
<div class="">However my request for a more concrete example
stands</div>
<div class=""><br class="">
</div>
<div class="">Here’s what I said</div>
<div class="">
<blockquote cite="mid:8D1216F2-8E1C-4895-8DA2-19932A92BD1B@sbcglobal.net" type="cite" style="background-color: rgb(255, 255, 255);" class="">
<div class="">This doesn’t make sense to me, a shift amount of
48 is “undefined” for unsigned char,</div>
<div class="">How do we know this isn’t a source code bug,</div>
<div class="">What makes us think the the user intended the
result to be “0”.</div>
</blockquote>
<br class="">
Here’s what Hal said in response<br style="background-color:
rgb(255, 255, 255);" class="">
<span style="background-color: rgb(255, 255, 255);" class="">>
As I said, this is representation of what the real code did,
and looked like, after other </span></div>
<div class=""><span style="background-color: rgb(255, 255, 255);" class="">> inlining had taken place, etc. In the original
form, the user's intent was </span></div>
<div class=""><span style="background-color: rgb(255, 255, 255);" class="">> clear. That code is never executed when T is a
small integer type.</span><br style="background-color:
rgb(255, 255, 255);" class="">
<br style="background-color: rgb(255, 255, 255);" class="">
</div>
<div class=""><br class="">
</div>
<div class="">The problem is I don’t know how to interpret what
Hal said here,</div>
<div class="">I can’t construct the “real” example from the
“representative” example</div>
<div class="">given his advise.</div>
</blockquote>
<br class="">
Hopefully, the description I later provided helps. I can't share the
"real" code, but I reconstructed this example from my memory of the
original code plus some of the intermediate IR I'd looked at.<br class="">
<br class="">
</div></div></blockquote></div><br class=""><div class="">Hal,</div><div class=""> I’d like to see if I understand you, here’s what I think, let me know if this is correct</div><div class=""><br class=""></div><div class="">1. Sometimes there are abstraction penalties in C++ code</div><div class="">2. That can be optimized away after template instantiation, function inlining, etc</div><div class="">3. When they for example exhibit this pattern</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>if (A) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>stuff;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>other stuff including “undefined behavior”;</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div class="">4. Where the compiler assumes “undefined behavior” doesn’t actually happen because</div><div class=""> In the C language standard it is the users responsibility to avoid it</div><div class="">5. Therefore in this example the compiler can a) delete the else-clause</div><div class=""> b) delete the if-cond, c) assume A is true and propagate that information</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Peter Lawrence.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>