<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 17, 2014 at 6:49 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Oct 17, 2014 at 5:17 PM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br></span><span class=""><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 style="word-wrap:break-word">Hi Sanjay,<div><br></div><div>I do not think this change is correct.</div><div>I have attached a test case with (before.ll) and without (after.ll) that change and the related C file (test.c).</div></div></blockquote><div><br></div></span><div><span style="color:rgb(0,0,0);font-family:'Courier New',Courier,monospace;font-size:14px;white-space:pre-wrap">signed short a = 8*8*8*548.54 - 3.14; // <-- the value of a is undef.</span><br></div><div><span style="color:rgb(0,0,0);font-family:'Courier New',Courier,monospace;font-size:14px;white-space:pre-wrap"><br></span></div>This line has undefined behavior; both C and C++ are very clear about this. The transformation is correct at the language semantics level. And it appears correct at the IR level too, whether you interpret "the results are undefined" as meaning undefined behavior or (strictly weaker) an undef value.</blockquote><div><br></div><div>I think it would be good to make the LangRef much more clear about this. I think "produces an undef value" is more concrete?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> It would be correct to treat this as poison, not just as undef, from a language semantics perspective.</blockquote></div><div class="gmail_extra"><br></div>I don't think there is any utility in thinking about poison here.... undef seems a good way to model this. I'm increasingly of the opinion we can all the optimizations we would ever want from undef alone.<br></div></div>