<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Could you make a patch out of the test case + the code change?<div class=""><br class=""></div><div class="">A couple more comment on the test case:</div><div class="">1. Use 'opt -instnamer' to get rid of the %[0-9]+ variables (you could do that manually since you only have one %0).</div><div class="">2. Add a comment explaining what this test is checking.</div><div class="">3. Add more check lines to make sure we generate something sane. (Like add a check for load and add, or whatever was touched by the LICM pass.)</div><div class="">4. You may want to use a triple instead of march for stability accross bot.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Q.<br class=""><div><blockquote type="cite" class=""><div class="">On Jun 8, 2016, at 4:34 PM, zan jyu Wong <<a href="mailto:zyfwong@gmail.com" class="">zyfwong@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">Hi,<br class=""><br class=""></div>The following is the test:<br class=""><br class=""><pre style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;" class="">; RUN: llc -march=thumb -sink-insts-to-avoid-spills -o - %s \<br class="">; RUN:     | FileCheck %s<br class="">; CHECK-LABEL: sum<br class=""><br class="">; Function Attrs: nounwind readonly<br class="">define arm_aapcscc i32 @sum(i32* noalias nocapture readonly %arr, i32 %c) {<br class="">entry:<br class="">  %cmp7 = icmp sgt i32 %c, 0<br class="">  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup<br class=""><br class="">for.body.preheader:                               ; preds = %entry<br class="">  %sp = tail call i32 asm "mov $0, sp", "=r"()<br class="">  br label %for.body<br class=""><br class="">for.cond.cleanup.loopexit:                        ; preds = %for.body<br class="">  br label %for.cond.cleanup<br class=""><br class="">for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry<br class="">  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]<br class="">  ret i32 %sum.0.lcssa<br class=""><br class="">for.body:                                         ; preds = %for.body, %for.body.preheader<br class="">  %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]<br class="">  %sum.08 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]<br class="">  %arrayidx = getelementptr inbounds i32, i32* %arr, i32 %i.09<br class="">  %0 = load i32, i32* %arrayidx, align 4<br class="">  %add = add nsw i32 %0, %sp<br class="">  %inc = add nuw nsw i32 %i.09, 1<br class="">  %exitcond = icmp eq i32 %inc, %c<br class="">  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body<br class="">}</pre></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 9, 2016 at 6:06 AM, Quentin Colombet <span dir="ltr" class=""><<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Hi Zan Jyu,</div><div class=""><br class=""></div>Great!<div class=""><br class=""></div><div class="">Add a few CHECK lines and get rid of the unused metadata and you should be good to go!</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Quentin<div class=""><div class="h5"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 7, 2016, at 9:06 PM, zan jyu Wong <<a href="mailto:zyfwong@gmail.com" target="_blank" class="">zyfwong@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">I've tried the following example on Thumb backend with the flags, it's ok?<br class=""></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br class=""></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">RUN: llc licm.ll -sink-insts-to-avoid-spills<br class=""><br class=""></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">========== example ===========<br class=""></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">; ModuleID = 'licm.c'<br class="">source_filename = "licm.c"<br class="">target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"<br class="">target triple = "armv4t--"<br class=""><br class="">; Function Attrs: nounwind readonly<br class="">define arm_aapcscc i32 @sum(i32* noalias nocapture readonly %arr, i32 %c) #0 {<br class="">entry:<br class="">  %cmp7 = icmp sgt i32 %c, 0<br class="">  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup<br class=""><br class="">for.body.preheader:                               ; preds = %entry<br class="">  %sp = tail call i32 asm "mov $0, sp", "=r"() #1, !srcloc !3<br class="">  br label %for.body<br class=""><br class="">for.cond.cleanup.loopexit:                        ; preds = %for.body<br class="">  br label %for.cond.cleanup<br class=""><br class="">for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry<br class="">  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]<br class="">  ret i32 %sum.0.lcssa<br class=""><br class="">for.body:                                         ; preds = %for.body.preheader, %for.body<br class="">  %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]<br class="">  %sum.08 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]<br class="">  %arrayidx = getelementptr inbounds i32, i32* %arr, i32 %i.09<br class="">  %0 = load i32, i32* %arrayidx, align 4, !tbaa !4<br class="">  %mul = mul nsw i32 %0, %sp<br class="">  %add = add nsw i32 %mul, %sum.08<br class="">  %inc = add nuw nsw i32 %i.09, 1<br class="">  %exitcond = icmp eq i32 %inc, %c<br class="">  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body<br class="">}<br class=""><br class="">attributes #0 = { nounwind readonly "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="arm7tdmi" "target-features"="+soft-float,+strict-align,-crypto,-neon" "unsafe-fp-math"="false" "use-soft-float"="true" }<br class="">attributes #1 = { nounwind readnone }<br class=""><br class="">!llvm.module.flags = !{!0, !1}<br class="">!llvm.ident = !{!2}<br class=""><br class="">!0 = !{i32 1, !"wchar_size", i32 4}<br class="">!1 = !{i32 1, !"min_enum_size", i32 4}<br class="">!2 = !{!"clang version 3.9.0 (<a href="http://llvm.org/git/clang.git" target="_blank" class="">http://llvm.org/git/clang.git</a> e8204bf8264d6d52aab4e8ac84328654d3ef28bd) (<a href="http://llvm.org/git/llvm.git" target="_blank" class="">http://llvm.org/git/llvm.git</a> d75f887d2fcccc1f0dbf7809c2638e2ff3448462)"}<br class="">!3 = !{i32 76}<br class="">!4 = !{!5, !5, i64 0}<br class="">!5 = !{!"long", !6, i64 0}<br class="">!6 = !{!"omnipotent char", !7, i64 0}<br class="">!7 = !{!"Simple C/C++ TBAA"}<br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 8, 2016 at 8:50 AM, Quentin Colombet <span dir="ltr" class=""><<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Could you try a simple example with that flag on x86_64 to produce a test case?<div class=""><br class=""></div><div class="">Thanks,</div><div class="">Q.<div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 7, 2016, at 5:38 PM, zan jyu Wong <<a href="mailto:zyfwong@gmail.com" target="_blank" class="">zyfwong@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">No. Since I'm working on a custom backend, unless I upload the backend.<br class=""></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">But there is an assertion in isDef(), so I think it can be reproduced on other backend when compile with -sink-insts-to-avoid-spills=true.<br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 8, 2016 at 12:03 AM, Quentin Colombet <span dir="ltr" class=""><<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Hi Zan Jyu,</div><div class=""><br class=""></div>Yep.<div class=""><br class=""></div><div class="">Do you have a test case to put with that?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin<br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">On Jun 7, 2016, at 12:25 AM, zan jyu Wong via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">We should test isReg() before isDef()<br class=""><br class="">diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp<br class="">index 00dec82..4ea0c56 100644<br class="">--- a/lib/CodeGen/MachineLICM.cpp<br class="">+++ b/lib/CodeGen/MachineLICM.cpp<br class="">@@ -716,7 +716,7 @@ void MachineLICM::SinkIntoLoop() {<br class=""> <br class="">   for (MachineInstr *I : Candidates) {<br class="">     const MachineOperand &MO = I->getOperand(0);<br class="">-    if (!MO.isDef() || !MO.isReg() || !MO.getReg())<br class="">+    if (!MO.isReg() || !MO.isDef() || !MO.getReg())<br class="">       continue;<br class="">     if (!MRI->hasOneDef(MO.getReg()))<br class="">       continue;<br class=""></div></div></div></div>
_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>