Skip to content

Commit f2dface

Browse files
committed
[PhaseOrdering] add test for llvm.expect; NFC
1 parent 9da3581 commit f2dface

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -O2 -S < %s | FileCheck %s
3+
4+
; FIXME:
5+
; Given an "expect" on a compare, we should not combine
6+
; that compare with other instructions in a way that the
7+
; backend can't undo. Expect lowering becomes metadata,
8+
; and passes like SimplifyCFG should respect that.
9+
10+
define void @PR49336(i32 %delta, i32 %tag_type, i8* %ip) {
11+
; CHECK-LABEL: @PR49336(
12+
; CHECK-NEXT: entry:
13+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp slt i32 [[DELTA:%.*]], 0
14+
; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[TAG_TYPE:%.*]], 0
15+
; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[TOBOOL]], [[CMP1]]
16+
; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_THEN2:%.*]], label [[IF_END3:%.*]]
17+
; CHECK: if.then2:
18+
; CHECK-NEXT: store i8 42, i8* [[IP:%.*]], align 1
19+
; CHECK-NEXT: br label [[IF_END3]]
20+
; CHECK: if.end3:
21+
; CHECK-NEXT: ret void
22+
;
23+
entry:
24+
%delta.addr = alloca i32, align 4
25+
%tag_type.addr = alloca i32, align 4
26+
%ip.addr = alloca i8*, align 8
27+
store i32 %delta, i32* %delta.addr, align 4
28+
store i32 %tag_type, i32* %tag_type.addr, align 4
29+
store i8* %ip, i8** %ip.addr, align 8
30+
%0 = load i32, i32* %delta.addr, align 4
31+
%cmp = icmp slt i32 %0, 0
32+
%conv = zext i1 %cmp to i64
33+
%expval = call i64 @llvm.expect.i64(i64 %conv, i64 0)
34+
%tobool = icmp ne i64 %expval, 0
35+
br i1 %tobool, label %if.then, label %if.end3
36+
37+
if.then:
38+
%1 = load i32, i32* %tag_type.addr, align 4
39+
%cmp1 = icmp ne i32 %1, 0
40+
br i1 %cmp1, label %if.then2, label %if.end
41+
42+
if.then2:
43+
%2 = load i8*, i8** %ip.addr, align 8
44+
store i8 42, i8* %2, align 1
45+
br label %if.end
46+
47+
if.end:
48+
br label %if.end3
49+
50+
if.end3:
51+
ret void
52+
}
53+
54+
declare i64 @llvm.expect.i64(i64, i64)

0 commit comments

Comments
 (0)