<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 class="">Hi Paul,</div><div class=""><br class=""></div><div class="">This is a bug with the test.</div><div class=""><br class=""></div><div class="">The various legalizerhelper methods expect that the MIRBuilder is pointing to the input MI when doing their expansions.</div><div class="">This is set automatically when you use the legalizeInstrStep API, but if you use another method directly, looks like this is the client responsibility to set it.</div><div class=""><br class=""></div><div class="">The patch below fixes your problem (you’ll have to do it for all of them).</div><div class=""><br class=""></div><div class="">It would be nice to have some kind of asserts here.</div><div class=""><br class=""></div><div class="">@Amara what do you think? </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp</b></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">index 5d31b6e876b8..dd7927acd6f5 100644</b></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp</b></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp</b></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">@@ -965,6 +965,9 @@</span><span style="font-variant-ligatures: no-common-ligatures" class=""> TEST_F(AArch64GISelMITest, MoreElementsAnd) {</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> TEST_F(AArch64GISelMITest, FewerElementsPhi) {</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">+</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">+ setUp();</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">+</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> if (!TM)</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> return;</span></div><p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">@@ -1027,6 +1030,7 @@</span><span style="font-variant-ligatures: no-common-ligatures" class=""> TEST_F(AArch64GISelMITest, FewerElementsPhi) {</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> // Add some use instruction after the phis.</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> B.buildAnd(PhiTy, Phi.getReg(0), Phi.getReg(0));</span></div><p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">+ B.setInstr(*Phi);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> EXPECT_EQ(LegalizerHelper::LegalizeResult::Legalized,</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> Helper.fewerElementsVector(*Phi, 0, v2s32));</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div><br class=""></div><div>Cheers,</div><div>-Quentin<br class=""><blockquote type="cite" class=""><div class="">On Jan 29, 2021, at 12:00 PM, <a href="mailto:paul.robinson@sony.com" class="">paul.robinson@sony.com</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><br class=""><blockquote type="cite" class="">-----Original Message-----<br class="">From: Quentin Colombet <<a href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>><br class="">Sent: Friday, January 29, 2021 1:32 PM<br class="">To: Robinson, Paul <<a href="mailto:paul.robinson@sony.com" class="">paul.robinson@sony.com</a>><br class="">Cc: <a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">Subject: Re: [llvm-dev] Q. about GlobalISel and order of instructions<br class=""><br class="">Hi Paul,<br class=""><br class="">Thanks for the heads-up!<br class=""><br class=""><blockquote type="cite" class="">On Jan 28, 2021, at 8:12 PM, via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class=""></blockquote>wrote:<br class=""><blockquote type="cite" class=""><br class="">Hello Global ISel fans,<br class=""><br class="">I am trying to patch up some unittests that accidentally weren't<br class="">actually running<br class=""></blockquote>(<a href="https://urldefense.com/v3/__https://reviews.llvm.org/D95257__;!!JmoZiZGBv" class="">https://urldefense.com/v3/__https://reviews.llvm.org/D95257__;!!JmoZiZGBv</a><br class="">3RvKRSx!pxOXw4x2XmGszxqKSXAovQkJx-<br class="">JyBTV988c1AXpEDJn9K0UNJwwjhVEcDTvbulL5Dw$ ). A number of<br class=""><blockquote type="cite" class="">these look like all the right instructions are coming out, but<br class="">they aren't "in the right order." That is, I see some tests<br class="">expect something along the lines of<br class=""><br class=""> %2:_(s16) = G_TRUNC<br class=""> %3:_(s10) = G_TRUNC %2:_(s16)<br class=""> %4:_(s10) = G_SEXT_INREG %3:_(s10)<br class=""> %5:_(s16) = G_SEXT %4:_(s10)<br class=""><br class="">That is, each instruction feeds nicely into the next one.<br class="">But what I'm actually seeing is reordered:<br class=""><br class=""> %5:_(s16) = G_SEXT %4:_(s10)<br class=""> %2:_(s16) = G_TRUNC<br class=""> %4:_(s10) = G_SEXT_INREG %3:_(s10)<br class=""> %3:_(s10) = G_TRUNC %2:_(s16)<br class=""><br class="">Now, I can certainly patch up the test to match the order I see,<br class="">but... Is that actually correct? Naively it looks like we have<br class="">uses preceding defs, which just looks weird.<br class=""></blockquote><br class="">That’s definitely broken!<br class=""><br class=""><blockquote type="cite" class=""><br class="">If the order I'm seeing is wrong (and it's just a standard dump<br class="">of a MachineFunction) then can somebody fix it?<br class=""></blockquote><br class="">Are these the tests you marked as FIXME in the PR you’ve linked?<br class=""></blockquote><br class="">Thanks, Quentin! Some of them have other more functional differences,<br class="">which are probably normal things where I can fix the test to match.<br class="">The ones that have just the ordering problem look like this set:<br class=""><br class="">FewerElementsPhi<br class="">WidenScalarBuildVector<br class="">WidenSEXTINREG<br class="">NarrowSEXTINREG<br class=""><br class="">Thanks!<br class="">--paulr<br class=""><br class=""><blockquote type="cite" class=""><br class="">Cheers,<br class="">-Quentin<br class=""><br class=""><blockquote type="cite" class=""> It will sure<br class="">make a lot less churn in the unittest.<br class=""><br class="">Thanks,<br class="">--paulr<br class=""><br class=""><br class="">_______________________________________________<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://urldefense.com/v3/__https://lists.llvm.org/cgi-<br class=""></blockquote>bin/mailman/listinfo/llvm-<br class="">dev__;!!JmoZiZGBv3RvKRSx!pxOXw4x2XmGszxqKSXAovQkJx-<br class="">JyBTV988c1AXpEDJn9K0UNJwwjhVEcDTsB1HBaAQ$<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></body></html>