<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 20, 2021, at 13:45, Rohit Aggarwal <<a href="mailto:cs18mtech11030@iith.ac.in" class="">cs18mtech11030@iith.ac.in</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" class="">Hi Florian,<div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 19, 2021 at 3:46 PM Florian Hahn <<a href="mailto:florian_hahn@apple.com" class="">florian_hahn@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div dir="ltr" class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><br class=""><blockquote type="cite" class="">On 19 Aug 2021, at 11:01, Rohit Aggarwal via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><br class=""></blockquote></div><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi All,<div class=""><br class=""></div><div class="">Thanks Florian for response.</div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""> Adding more details to the issue:</div><div class=""><ul class=""><li class="">I revert the commit  <a href="https://github.com/llvm/llvm-project/commit/2fd3037ac615643fe8058292d2b89bb19a49cb2f#" target="_blank" class="">[ConstantFold] Allow propagation of poison for and/or i1</a> then it is working fine.</li><li class="">In this commit, a check is removed to stop the constantfold of instruction to poison value incase of integer ADD or OR instruction if either of operands are poison.</li><li class="">Using both release branch and commit reverted branch, a poison value is generated by a shift left instruction due to overflow (UB is present) </li></ul></div></div></div></div></div></blockquote><div class=""><br class=""></div>Ok so it sounds like this is the reason for the different output and the transformation is correct.</div></blockquote><div class="">    >> Yes, this poison which is generated is handled differently in llvm-trunk and reverted commit code down the pipeline. </div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><ul class=""><li class="">Now in the release branch, this poison value is propagated down to 'or' inst. and  is constantfolds %or = or  true poison  -> poison  </li></ul></div></div></div></blockquote></div></blockquote><div class=""><br class=""></div><div class=""><ul class=""><li class="">where as in the reverted code,  %or = or  true poison  -> true</li></ul></div><div class="">  >> Here is the main reason, where the problem started </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><ul class=""><li class="">In the release branch, the poison value propagates to its uses</li><li class="">There is a store instruction which now has a poison value</li><li class="">In visitStoreInst, store instruction got removed due to poison value</li><li class="">But in revert branch, store is not getting remove as it has defined value</li></ul></div></div></div></div></div></blockquote></div></div></blockquote></div></div></div></blockquote>Sure, the change in instcombine propagates poison more aggressively. But as far as I can tell, this is in line with the semantics specified in LangRef and the transformation is correct. The reason for the change in output seems to be that instcombine was taught to exploit the undefined behavior in this case.</div><div><br class=""></div><div>If this change in output is causing any issues, I’d suggest you check the source file from which the LLVM IR has been generated for any undefined behavior and fix it.</div><div><br class=""></div><div>If the input source file is well defined, I’d suggest to check where the poison value causing issues comes from.</div><br class=""><div class="">Cheers,</div><div class="">Florian</div></body></html>