1; RUN: llc < %s -march=x86 -regalloc=greedy --debug-only=regalloc 2>&1 | FileCheck %s 2 3; REQUIRES: asserts 4 5; This test is meant to make sure that the weight of local intervals that are 6; created during split is taken into account when choosing the best candidate 7; register. 8; %shl is the interval that will be split. 9; The inline assembly calls interfere with %shl and make only 2 available split 10; candidates - %esi and %ebp. 11; The old code would have chosen %esi as the split candidate ignoring the fact 12; that this choice will cause the creation of a local interval that will have a 13; certain spill cost. 14; The new code choses %ebp as the split candidate as it has lower spill cost. 15 16; Make sure the split behaves as expected 17; CHECK: RS_Split Cascade 1 18; CHECK-NOT: $eax static = 19; CHECK: $eax no positive bundles 20; CHECK-NEXT: $ecx no positive bundles 21; CHECK-NEXT: $edx no positive bundles 22; CHECK-NEXT: $esi static = 23; CHECK-NEXT: $edi no positive bundles 24; CHECK-NEXT: $ebx no positive bundles 25; CHECK-NEXT: $ebp static = 26; CHECK: Split for $ebp 27 28; Function Attrs: nounwind 29define i32 @foo(i32* %array, i32 %cond1, i32 %val) local_unnamed_addr #0 { 30entry: 31 %array.addr = alloca i32*, align 4 32 store i32* %array, i32** %array.addr, align 4, !tbaa !3 33 %0 = load i32, i32* %array, align 4, !tbaa !7 34 %arrayidx1 = getelementptr inbounds i32, i32* %array, i32 1 35 %1 = load i32, i32* %arrayidx1, align 4, !tbaa !7 36 %arrayidx2 = getelementptr inbounds i32, i32* %array, i32 2 37 %2 = load i32, i32* %arrayidx2, align 4, !tbaa !7 38 %arrayidx3 = getelementptr inbounds i32, i32* %array, i32 3 39 %3 = load i32, i32* %arrayidx3, align 4, !tbaa !7 40 %arrayidx4 = getelementptr inbounds i32, i32* %array, i32 4 41 %4 = load i32, i32* %arrayidx4, align 4, !tbaa !7 42 %arrayidx6 = getelementptr inbounds i32, i32* %array, i32 %val 43 %5 = load i32, i32* %arrayidx6, align 4, !tbaa !7 44 %shl = shl i32 %5, 5 45 %tobool = icmp eq i32 %cond1, 0 46 br i1 %tobool, label %if.else, label %if.then 47 48if.then: ; preds = %entry 49 %arrayidx7 = getelementptr inbounds i32, i32* %array, i32 6 50 store i32 %shl, i32* %arrayidx7, align 4, !tbaa !7 51 call void asm "nop", "=*m,r,r,r,r,r,*m,~{dirflag},~{fpsr},~{flags}"(i32** nonnull %array.addr, i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32** nonnull %array.addr) #1, !srcloc !9 52 %6 = load i32*, i32** %array.addr, align 4, !tbaa !3 53 %arrayidx8 = getelementptr inbounds i32, i32* %6, i32 7 54 br label %if.end 55 56if.else: ; preds = %entry 57 %arrayidx5 = getelementptr inbounds i32, i32* %array, i32 5 58 %7 = load i32, i32* %arrayidx5, align 4, !tbaa !7 59 %arrayidx9 = getelementptr inbounds i32, i32* %array, i32 8 60 store i32 %shl, i32* %arrayidx9, align 4, !tbaa !7 61 call void asm "nop", "=*m,{ax},{bx},{cx},{dx},{di},{si},{ebp},*m,~{dirflag},~{fpsr},~{flags}"(i32** nonnull %array.addr, i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %7, i32* undef, i32** nonnull %array.addr) #1, !srcloc !10 62 %8 = load i32*, i32** %array.addr, align 4, !tbaa !3 63 %arrayidx10 = getelementptr inbounds i32, i32* %8, i32 9 64 br label %if.end 65 66if.end: ; preds = %if.else, %if.then 67 %arrayidx10.sink = phi i32* [ %arrayidx10, %if.else ], [ %arrayidx8, %if.then ] 68 %9 = phi i32* [ %8, %if.else ], [ %6, %if.then ] 69 store i32 %shl, i32* %arrayidx10.sink, align 4, !tbaa !7 70 %10 = load i32, i32* %9, align 4, !tbaa !7 71 %add = add nsw i32 %10, %shl 72 ret i32 %add 73} 74 75attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 76attributes #1 = { nounwind } 77 78!llvm.module.flags = !{!0, !1} 79!llvm.ident = !{!2} 80 81!0 = !{i32 1, !"NumRegisterParameters", i32 0} 82!1 = !{i32 1, !"wchar_size", i32 4} 83!2 = !{!"clang version 6.0.0"} 84!3 = !{!4, !4, i64 0} 85!4 = !{!"any pointer", !5, i64 0} 86!5 = !{!"omnipotent char", !6, i64 0} 87!6 = !{!"Simple C/C++ TBAA"} 88!7 = !{!8, !8, i64 0} 89!8 = !{!"int", !5, i64 0} 90!9 = !{i32 268} 91!10 = !{i32 390} 92