<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><blockquote type="cite" class=""><div class="">On Jan 17, 2021, at 10:11 PM, Cassie Jones via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">I was looking at the overflowing operations because I was trying to deal with the legalization and selection of wide adds, and I wasn’t sure on the finer points of some of the semantics.</div><div class="">I’m specifically looking at the addition/subtraction operations:</div><div class=""><br class=""></div><div class=""><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">    G_UADDO, G_SADDO, G_USUBO, G_SSUBO</span></font></div><div class=""><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">    G_UADDE, G_SADDE, G_USUBE, G_SSUBE</span></font></div><div class=""><br class=""></div><div class="">Is it correct that the <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">S*</span></font> operations set the carry-out value when they have a signed overflow, and the <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">U*</span></font> operations when they have an unsigned overflow?</div></div></div></blockquote>Yes, they’re directly mapped from the IR intrinsics: <a href="https://llvm.org/docs/LangRef.html#llvm-sadd-with-overflow-intrinsics" class="">https://llvm.org/docs/LangRef.html#llvm-sadd-with-overflow-intrinsics</a><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Particularly, is there any difference between them if the carry-out isn’t used by anything?</div></div></div></blockquote>If by carry-out you mean the i1 result value, then yes I think the actual addition part is the same.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">I would expect that a decomposed wide add would have a sequence like the following:</div><div class=""><br class=""></div><div class=""><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">    G_UADDO</span></font></div><div class=""><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">    G_UADDE</span></font></div><div class=""><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">    ...</span></font></div><div class=""><br class=""></div><div class="">Would that just need to end with a <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">G_SADDE</span></font> when implementing an operation like Rust's <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">i128::checked_add()</span></font>?</div></div></div></blockquote>Not sure why there would be a mixing of unsigned/signed, but for splitting of wide addition, we use G_UADDO + G_UADDE in LegalizerHelper::narrowScalar() with the G_ADD case.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Finally, Is there a reason that <font face="FiraCode-Regular" class="">G_SADDE</font> and <font face="FiraCode-Regular" class="">G_SSUBE</font> aren’t legal in the AArch64 backend? (Particularly while <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">G_SADDO</span></font> and <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">G_SSUBO</span></font> are.)</div><div class="">They seem like they have the potential to produce bad code if used in the middle of a sequence like that, but I don’t know if that’s a reason to make them illegal so I was wondering if there was something else I was missing.</div></div></div></blockquote>Anything illegal will just be due to the fact that we haven’t yet implemented support for it. Some operations pop up in IR for C++/ObjC more often than others, so those operations have higher priority when implementing.</div><div><br class=""></div><div>Thanks,</div><div>Amara<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Thanks,</div><div class="">— Cassie</div><div class=""><br class=""></div></div>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>