2014-05-24 14:50:23 +02:00
|
|
|
; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
|
2013-01-31 13:12:40 +01:00
|
|
|
|
|
|
|
; This test checks that LLVM can do basic stripping and reapplying of branches
|
|
|
|
; to basic blocks.
|
|
|
|
|
|
|
|
declare void @test_true()
|
|
|
|
declare void @test_false()
|
|
|
|
|
|
|
|
; !0 corresponds to a branch being taken, !1 to not being takne.
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-15 20:07:53 +01:00
|
|
|
!0 = !{!"branch_weights", i32 64, i32 4}
|
|
|
|
!1 = !{!"branch_weights", i32 4, i32 64}
|
2013-01-31 13:12:40 +01:00
|
|
|
|
|
|
|
define void @test_Bcc_fallthrough_taken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_Bcc_fallthrough_taken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp eq i32 %in, 42
|
|
|
|
br i1 %tst, label %true, label %false, !prof !0
|
|
|
|
|
|
|
|
; CHECK: cmp {{w[0-9]+}}, #42
|
|
|
|
|
|
|
|
; CHECK: b.ne [[FALSE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_true
|
|
|
|
|
|
|
|
; CHECK: [[FALSE]]:
|
|
|
|
; CHECK: bl test_false
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_Bcc_fallthrough_nottaken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_Bcc_fallthrough_nottaken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp eq i32 %in, 42
|
|
|
|
br i1 %tst, label %true, label %false, !prof !1
|
|
|
|
|
|
|
|
; CHECK: cmp {{w[0-9]+}}, #42
|
|
|
|
|
|
|
|
; CHECK: b.eq [[TRUE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_false
|
|
|
|
|
|
|
|
; CHECK: [[TRUE]]:
|
|
|
|
; CHECK: bl test_true
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_CBZ_fallthrough_taken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_CBZ_fallthrough_taken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp eq i32 %in, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !0
|
|
|
|
|
|
|
|
; CHECK: cbnz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_true
|
|
|
|
|
|
|
|
; CHECK: [[FALSE]]:
|
|
|
|
; CHECK: bl test_false
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_CBZ_fallthrough_nottaken(i64 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_CBZ_fallthrough_nottaken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp eq i64 %in, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !1
|
|
|
|
|
|
|
|
; CHECK: cbz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_false
|
|
|
|
|
|
|
|
; CHECK: [[TRUE]]:
|
|
|
|
; CHECK: bl test_true
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_CBNZ_fallthrough_taken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_CBNZ_fallthrough_taken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp ne i32 %in, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !0
|
|
|
|
|
|
|
|
; CHECK: cbz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_true
|
|
|
|
|
|
|
|
; CHECK: [[FALSE]]:
|
|
|
|
; CHECK: bl test_false
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_CBNZ_fallthrough_nottaken(i64 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_CBNZ_fallthrough_nottaken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%tst = icmp ne i64 %in, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !1
|
|
|
|
|
|
|
|
; CHECK: cbnz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_false
|
|
|
|
|
|
|
|
; CHECK: [[TRUE]]:
|
|
|
|
; CHECK: bl test_true
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_TBZ_fallthrough_taken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_TBZ_fallthrough_taken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%bit = and i32 %in, 32768
|
|
|
|
%tst = icmp eq i32 %bit, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !0
|
|
|
|
|
|
|
|
; CHECK: tbnz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_true
|
|
|
|
|
|
|
|
; CHECK: [[FALSE]]:
|
|
|
|
; CHECK: bl test_false
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_TBZ_fallthrough_nottaken(i64 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_TBZ_fallthrough_nottaken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%bit = and i64 %in, 32768
|
|
|
|
%tst = icmp eq i64 %bit, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !1
|
|
|
|
|
2014-04-14 14:50:58 +02:00
|
|
|
; CHECK: tbz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_false
|
|
|
|
|
|
|
|
; CHECK: [[TRUE]]:
|
|
|
|
; CHECK: bl test_true
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define void @test_TBNZ_fallthrough_taken(i32 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_TBNZ_fallthrough_taken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%bit = and i32 %in, 32768
|
|
|
|
%tst = icmp ne i32 %bit, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !0
|
|
|
|
|
|
|
|
; CHECK: tbz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_true
|
|
|
|
|
|
|
|
; CHECK: [[FALSE]]:
|
|
|
|
; CHECK: bl test_false
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_TBNZ_fallthrough_nottaken(i64 %in) nounwind {
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test_TBNZ_fallthrough_nottaken:
|
2013-01-31 13:12:40 +01:00
|
|
|
%bit = and i64 %in, 32768
|
|
|
|
%tst = icmp ne i64 %bit, 0
|
|
|
|
br i1 %tst, label %true, label %false, !prof !1
|
|
|
|
|
2014-04-14 14:50:58 +02:00
|
|
|
; CHECK: tbnz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
|
2017-12-04 18:18:51 +01:00
|
|
|
; CHECK-NEXT: // %bb.
|
2013-01-31 13:12:40 +01:00
|
|
|
; CHECK-NEXT: bl test_false
|
|
|
|
|
|
|
|
; CHECK: [[TRUE]]:
|
|
|
|
; CHECK: bl test_true
|
|
|
|
|
|
|
|
true:
|
|
|
|
call void @test_true()
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false:
|
|
|
|
call void @test_false()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|