Skip to content

Commit 73f087b

Browse files
authored
[NFC][SelectionDAG] Replace generic @llvm.expect.with.probability codegen test with X86 test (#117848)
Adds test case for X86 to check that the output of @llvm.expect.with.probability's generic lowering is reasonable. This replaces a generic test which only asserts that llc does not crash.
1 parent a09df64 commit 73f087b

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

llvm/test/CodeGen/Generic/builtin-expect-with-probability.ll

Lines changed: 0 additions & 8 deletions
This file was deleted.

llvm/test/CodeGen/X86/fast-isel-expect.ll

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
12
; RUN: llc < %s -O0 | FileCheck %s
23

34
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
@@ -6,9 +7,17 @@ target triple = "i686-unknown-linux-gnu"
67
@glbl = extern_weak constant i8
78

89
declare i64 @llvm.expect.i64(i64, i64)
10+
declare i64 @llvm.expect.with.probability.i64(i64, i64, double)
911

10-
define void @test() {
11-
; CHECK: movl $glbl
12+
define void @test_expect() {
13+
; CHECK-LABEL: test_expect:
14+
; CHECK: # %bb.0:
15+
; CHECK-NEXT: movl $glbl, %eax
16+
; CHECK-NEXT: testl %eax, %eax
17+
; CHECK-NEXT: jne .LBB0_2
18+
; CHECK-NEXT: jmp .LBB0_1
19+
; CHECK-NEXT: .LBB0_1: # %bb1
20+
; CHECK-NEXT: .LBB0_2: # %bb2
1221
%cmp2 = icmp eq ptr @glbl, null
1322
%ext = zext i1 %cmp2 to i64
1423
%tmp = call i64 @llvm.expect.i64(i64 %ext, i64 0)
@@ -21,3 +30,25 @@ bb1:
2130
bb2:
2231
unreachable
2332
}
33+
34+
define void @test_expect_with_probability() {
35+
; CHECK-LABEL: test_expect_with_probability:
36+
; CHECK: # %bb.0:
37+
; CHECK-NEXT: movl $glbl, %eax
38+
; CHECK-NEXT: testl %eax, %eax
39+
; CHECK-NEXT: jne .LBB1_2
40+
; CHECK-NEXT: jmp .LBB1_1
41+
; CHECK-NEXT: .LBB1_1: # %bb1
42+
; CHECK-NEXT: .LBB1_2: # %bb2
43+
%cmp2 = icmp eq ptr @glbl, null
44+
%ext = zext i1 %cmp2 to i64
45+
%tmp = call i64 @llvm.expect.with.probability.i64(i64 %ext, i64 0, double 0.5)
46+
%tmp2 = icmp ne i64 %tmp, 0
47+
br i1 %tmp2, label %bb1, label %bb2
48+
49+
bb1:
50+
unreachable
51+
52+
bb2:
53+
unreachable
54+
}

0 commit comments

Comments
 (0)