<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=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 16, 2020, at 6:47 AM, Devadasan, Christudasan <<a href="mailto:Christudasan.Devadasan@amd.com" class="">Christudasan.Devadasan@amd.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div class="WordSection1" style="page: WordSection1; 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;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi All,<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I was trying to legalize the family of memcpy intrinsics (memcpy, memmove and memset) for AMDGPU and<span class="Apple-converted-space"> </span><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">found that the combiner functions optimizeMemcpy, optimizeMemmove and optimizeMemset implemented in CombinerHelper.cpp pretty much handle these lowering.</span><o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">Can we move these functions to Legalizer entirely and perform a custom legalization to handle their expansion?<o:p class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">The reason is, in the Combiner it is more of an optimization action rather than something required always for correctness.</span></div></div></div></blockquote>Right, that’s how this is implemented in SelectionDAG too, it’s an optimization that may or may not fire depending on the heuristics.</div><div><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; 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;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class=""><o:p class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">On the other hand, if these combiner expansions turned out to be unavoidable, we should move these function into a common file.<o:p class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">In that way, both Legalizer and Combiner can take advantage of them.</span></div></div></div></blockquote>I think refactoring it to be shared is ok, but I and others disagree that this is a legalization issue rather than a combiner. There is no question of legality here, the target should be able to handle these opcodes. If they’re not legal for your target, then you could simply not use the expansion combines and handle them using custom legalization like any other operation.</div><div><br class=""></div><div>Amara<br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; 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;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class=""><o:p class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10.5pt; font-family: -apple-system; color: rgb(23, 43, 77); background-color: white; background-position: initial initial; background-repeat: initial initial;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Regards,<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">CD</div></div></div></blockquote></div><br class=""></body></html>