mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
[Tests] Add tests for non-speculatable ephemeral values
The loads in these examples are currently not considered ephemeral because they are not speculatable.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
; RUN: opt -S -inline %s -debug-only=inline-cost 2>&1 | FileCheck %s
|
||||
; REQUIRES: asserts
|
||||
; Only the load and ret should be included in the instruction count, not
|
||||
; the instructions feeding the assume.
|
||||
; CHECK: NumInstructions: 2
|
||||
|
||||
@a = global i32 4
|
||||
|
||||
; Only the load and ret should be included in the instruction count, not
|
||||
; the instructions feeding the assume.
|
||||
; CHECK: Analyzing call of inner...
|
||||
; CHECK: NumInstructions: 2
|
||||
define i32 @inner(i8* %y) {
|
||||
%a1 = load volatile i32, i32* @a
|
||||
|
||||
@@ -25,8 +26,20 @@ define i32 @inner(i8* %y) {
|
||||
ret i32 %a1
|
||||
}
|
||||
|
||||
; TODO: The load should be considered ephemeral here, even though it is not
|
||||
; speculatable.
|
||||
; CHECK: Analyzing call of inner2...
|
||||
; CHECK: NumInstructions: 2
|
||||
define void @inner2(i8* %y) {
|
||||
%v = load i8, i8* %y
|
||||
%c = icmp eq i8 %v, 42
|
||||
call void @llvm.assume(i1 %c)
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @outer(i8* %y) optsize {
|
||||
%r = call i32 @inner(i8* %y)
|
||||
call void @inner2(i8* %y)
|
||||
ret i32 %r
|
||||
}
|
||||
|
||||
|
||||
@@ -232,3 +232,58 @@ false2: ; preds = %true1
|
||||
store volatile i64 3, i64* %ptr, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; TODO: The load should be considered ephemeral here, even though it is not
|
||||
; speculatable.
|
||||
define void @test_non_speculatable(i1 %c, i64* align 1 %ptr, i8* %ptr2) local_unnamed_addr #0 {
|
||||
; CHECK-LABEL: @test_non_speculatable(
|
||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[TRUE1:%.*]], label [[FALSE1:%.*]]
|
||||
; CHECK: true1:
|
||||
; CHECK-NEXT: [[V:%.*]] = load i8, i8* [[PTR2:%.*]], align 1
|
||||
; CHECK-NEXT: [[C2:%.*]] = icmp eq i8 [[V]], 42
|
||||
; CHECK-NEXT: call void @llvm.assume(i1 [[C2]])
|
||||
; CHECK-NEXT: store volatile i64 0, i64* [[PTR:%.*]], align 8
|
||||
; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: br i1 [[C]], label [[TRUE2:%.*]], label [[FALSE2:%.*]]
|
||||
; CHECK: false1:
|
||||
; CHECK-NEXT: store volatile i64 1, i64* [[PTR]], align 4
|
||||
; CHECK-NEXT: br label [[TRUE1]]
|
||||
; CHECK: common.ret:
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK: true2:
|
||||
; CHECK-NEXT: store volatile i64 2, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
|
||||
; CHECK: false2:
|
||||
; CHECK-NEXT: store volatile i64 3, i64* [[PTR]], align 8
|
||||
; CHECK-NEXT: br label [[COMMON_RET]]
|
||||
;
|
||||
br i1 %c, label %true1, label %false1
|
||||
|
||||
true1: ; preds = %false1, %0
|
||||
%v = load i8, i8* %ptr2
|
||||
%c2 = icmp eq i8 %v, 42
|
||||
call void @llvm.assume(i1 %c2)
|
||||
store volatile i64 0, i64* %ptr, align 8
|
||||
store volatile i64 -1, i64* %ptr, align 8
|
||||
store volatile i64 -1, i64* %ptr, align 8
|
||||
store volatile i64 -1, i64* %ptr, align 8
|
||||
store volatile i64 -1, i64* %ptr, align 8
|
||||
store volatile i64 -1, i64* %ptr, align 8
|
||||
br i1 %c, label %true2, label %false2
|
||||
|
||||
false1: ; preds = %0
|
||||
store volatile i64 1, i64* %ptr, align 4
|
||||
br label %true1
|
||||
|
||||
true2: ; preds = %true1
|
||||
store volatile i64 2, i64* %ptr, align 8
|
||||
ret void
|
||||
|
||||
false2: ; preds = %true1
|
||||
store volatile i64 3, i64* %ptr, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user