xref: /llvm-project/llvm/test/CodeGen/X86/code_placement_loop_rotation.ll (revision 029a0567fa9f2e280a1ff7641bfe0c5a87f14922)
1*029a0567SMandeep Singh Grang; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s
27745dbc5SCong Hou; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -precise-rotation-cost < %s | FileCheck %s -check-prefix=CHECK-PROFILE
37745dbc5SCong Hou
47745dbc5SCong Houdefine void @foo() {
57745dbc5SCong Hou; Test that not all edges in the loop chain are fall through without profile
67745dbc5SCong Hou; data.
77745dbc5SCong Hou;
87745dbc5SCong Hou; CHECK-LABEL: foo:
97745dbc5SCong Hou; CHECK: callq e
107745dbc5SCong Hou; CHECK: callq f
117745dbc5SCong Hou; CHECK: callq g
127745dbc5SCong Hou; CHECK: callq h
137745dbc5SCong Hou
147745dbc5SCong Houentry:
157745dbc5SCong Hou  br label %header
167745dbc5SCong Hou
177745dbc5SCong Houheader:
187745dbc5SCong Hou  call void @e()
197745dbc5SCong Hou  %call = call zeroext i1 @a()
207745dbc5SCong Hou  br i1 %call, label %if.then, label %if.else, !prof !2
217745dbc5SCong Hou
227745dbc5SCong Houif.then:
237745dbc5SCong Hou  call void @f()
247745dbc5SCong Hou  br label %if.end
257745dbc5SCong Hou
267745dbc5SCong Houif.else:
277745dbc5SCong Hou  call void @g()
287745dbc5SCong Hou  br label %if.end
297745dbc5SCong Hou
307745dbc5SCong Houif.end:
317745dbc5SCong Hou  call void @h()
327745dbc5SCong Hou  %call2 = call zeroext i1 @a()
337745dbc5SCong Hou  br i1 %call2, label %header, label %end
347745dbc5SCong Hou
357745dbc5SCong Houend:
367745dbc5SCong Hou  ret void
377745dbc5SCong Hou}
387745dbc5SCong Hou
397745dbc5SCong Houdefine void @bar() !prof !1 {
407745dbc5SCong Hou; Test that all edges in the loop chain are fall through with profile data.
417745dbc5SCong Hou;
427745dbc5SCong Hou; CHECK-PROFILE-LABEL: bar:
437745dbc5SCong Hou; CHECK-PROFILE: callq g
447745dbc5SCong Hou; CHECK-PROFILE: callq h
457745dbc5SCong Hou; CHECK-PROFILE: callq e
467745dbc5SCong Hou; CHECK-PROFILE: callq f
477745dbc5SCong Hou
487745dbc5SCong Houentry:
497745dbc5SCong Hou  br label %header
507745dbc5SCong Hou
517745dbc5SCong Houheader:
527745dbc5SCong Hou  call void @e()
537745dbc5SCong Hou  %call = call zeroext i1 @a()
547745dbc5SCong Hou  br i1 %call, label %if.then, label %if.else, !prof !2
557745dbc5SCong Hou
567745dbc5SCong Houif.then:
577745dbc5SCong Hou  call void @f()
587745dbc5SCong Hou  br label %if.end
597745dbc5SCong Hou
607745dbc5SCong Houif.else:
617745dbc5SCong Hou  call void @g()
627745dbc5SCong Hou  br label %if.end
637745dbc5SCong Hou
647745dbc5SCong Houif.end:
657745dbc5SCong Hou  call void @h()
667745dbc5SCong Hou  %call2 = call zeroext i1 @a()
677745dbc5SCong Hou  br i1 %call2, label %header, label %end
687745dbc5SCong Hou
697745dbc5SCong Houend:
707745dbc5SCong Hou  ret void
717745dbc5SCong Hou}
727745dbc5SCong Hou
737745dbc5SCong Houdeclare zeroext i1 @a()
747745dbc5SCong Houdeclare void @e()
757745dbc5SCong Houdeclare void @f()
767745dbc5SCong Houdeclare void @g()
777745dbc5SCong Houdeclare void @h()
787745dbc5SCong Hou
797745dbc5SCong Hou!1 = !{!"function_entry_count", i64 1}
807745dbc5SCong Hou!2 = !{!"branch_weights", i32 16, i32 16}
81