<div dir="ltr"><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><br></div>The following is the test:<br><br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"Menlo";font-size:9pt">; RUN: llc -march=thumb -sink-insts-to-avoid-spills -o - %s \<br>; RUN:     | FileCheck %s<br>; CHECK-LABEL: sum<br><br>; Function Attrs: nounwind readonly<br>define arm_aapcscc i32 @sum(i32* noalias nocapture readonly %arr, i32 %c) {<br>entry:<br>  %cmp7 = icmp sgt i32 %c, 0<br>  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup<br><br>for.body.preheader:                               ; preds = %entry<br>  %sp = tail call i32 asm "mov $0, sp", "=r"()<br>  br label %for.body<br><br>for.cond.cleanup.loopexit:                        ; preds = %for.body<br>  br label %for.cond.cleanup<br><br>for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry<br>  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]<br>  ret i32 %sum.0.lcssa<br><br>for.body:                                         ; preds = %for.body, %for.body.preheader<br>  %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]<br>  %sum.08 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]<br>  %arrayidx = getelementptr inbounds i32, i32* %arr, i32 %i.09<br>  %0 = load i32, i32* %arrayidx, align 4<br>  %add = add nsw i32 %0, %sp<br>  %inc = add nuw nsw i32 %i.09, 1<br>  %exitcond = icmp eq i32 %inc, %c<br>  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body<br>}</pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 9, 2016 at 6:06 AM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Zan Jyu,</div><div><br></div>Great!<div><br></div><div>Add a few CHECK lines and get rid of the unused metadata and you should be good to go!</div><div><br></div><div>Cheers,</div><div>-Quentin<div><div class="h5"><br><div><blockquote type="cite"><div>On Jun 7, 2016, at 9:06 PM, zan jyu Wong <<a href="mailto:zyfwong@gmail.com" target="_blank">zyfwong@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><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></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">RUN: llc licm.ll -sink-insts-to-avoid-spills<br><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">========== example ===========<br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">; ModuleID = 'licm.c'<br>source_filename = "licm.c"<br>target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"<br>target triple = "armv4t--"<br><br>; Function Attrs: nounwind readonly<br>define arm_aapcscc i32 @sum(i32* noalias nocapture readonly %arr, i32 %c) #0 {<br>entry:<br>  %cmp7 = icmp sgt i32 %c, 0<br>  br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup<br><br>for.body.preheader:                               ; preds = %entry<br>  %sp = tail call i32 asm "mov $0, sp", "=r"() #1, !srcloc !3<br>  br label %for.body<br><br>for.cond.cleanup.loopexit:                        ; preds = %for.body<br>  br label %for.cond.cleanup<br><br>for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry<br>  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]<br>  ret i32 %sum.0.lcssa<br><br>for.body:                                         ; preds = %for.body.preheader, %for.body<br>  %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]<br>  %sum.08 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]<br>  %arrayidx = getelementptr inbounds i32, i32* %arr, i32 %i.09<br>  %0 = load i32, i32* %arrayidx, align 4, !tbaa !4<br>  %mul = mul nsw i32 %0, %sp<br>  %add = add nsw i32 %mul, %sum.08<br>  %inc = add nuw nsw i32 %i.09, 1<br>  %exitcond = icmp eq i32 %inc, %c<br>  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body<br>}<br><br>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>attributes #1 = { nounwind readnone }<br><br>!llvm.module.flags = !{!0, !1}<br>!llvm.ident = !{!2}<br><br>!0 = !{i32 1, !"wchar_size", i32 4}<br>!1 = !{i32 1, !"min_enum_size", i32 4}<br>!2 = !{!"clang version 3.9.0 (<a href="http://llvm.org/git/clang.git" target="_blank">http://llvm.org/git/clang.git</a> e8204bf8264d6d52aab4e8ac84328654d3ef28bd) (<a href="http://llvm.org/git/llvm.git" target="_blank">http://llvm.org/git/llvm.git</a> d75f887d2fcccc1f0dbf7809c2638e2ff3448462)"}<br>!3 = !{i32 76}<br>!4 = !{!5, !5, i64 0}<br>!5 = !{!"long", !6, i64 0}<br>!6 = !{!"omnipotent char", !7, i64 0}<br>!7 = !{!"Simple C/C++ TBAA"}<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 8, 2016 at 8:50 AM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Could you try a simple example with that flag on x86_64 to produce a test case?<div><br></div><div>Thanks,</div><div>Q.<div><div><br><div><blockquote type="cite"><div>On Jun 7, 2016, at 5:38 PM, zan jyu Wong <<a href="mailto:zyfwong@gmail.com" target="_blank">zyfwong@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><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></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></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 8, 2016 at 12:03 AM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Zan Jyu,</div><div><br></div>Yep.<div><br></div><div>Do you have a test case to put with that?</div><div><br></div><div>Thanks,</div><div>-Quentin<br><div><blockquote type="cite"><div><div><div>On Jun 7, 2016, at 12:25 AM, zan jyu Wong via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:</div><br></div></div><div><div><div><div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">We should test isReg() before isDef()<br><br>diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp<br>index 00dec82..4ea0c56 100644<br>--- a/lib/CodeGen/MachineLICM.cpp<br>+++ b/lib/CodeGen/MachineLICM.cpp<br>@@ -716,7 +716,7 @@ void MachineLICM::SinkIntoLoop() {<br> <br>   for (MachineInstr *I : Candidates) {<br>     const MachineOperand &MO = I->getOperand(0);<br>-    if (!MO.isDef() || !MO.isReg() || !MO.getReg())<br>+    if (!MO.isReg() || !MO.isDef() || !MO.getReg())<br>       continue;<br>     if (!MRI->hasOneDef(MO.getReg()))<br>       continue;<br></div></div></div></div>
_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>