1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -O2 -S < %s | FileCheck %s
4 ; Given an "expect" on a compare, we should not combine
5 ; that compare with other instructions in a way that the
6 ; backend can't undo. Expect lowering becomes metadata,
7 ; and passes like SimplifyCFG should respect that.
9 define void @PR49336(i32 %delta, i32 %tag_type, ptr %ip) {
10 ; CHECK-LABEL: @PR49336(
12 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[DELTA:%.*]], 0
13 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END3:%.*]], !prof !0
15 ; CHECK-NEXT: [[CMP1_NOT:%.*]] = icmp eq i32 [[TAG_TYPE:%.*]], 0
16 ; CHECK-NEXT: br i1 [[CMP1_NOT]], label [[IF_END3]], label [[IF_THEN2:%.*]]
18 ; CHECK-NEXT: store i8 42, ptr [[IP:%.*]], align 1
19 ; CHECK-NEXT: br label [[IF_END3]]
21 ; CHECK-NEXT: ret void
24 %delta.addr = alloca i32, align 4
25 %tag_type.addr = alloca i32, align 4
26 %ip.addr = alloca ptr, align 8
27 store i32 %delta, ptr %delta.addr, align 4
28 store i32 %tag_type, ptr %tag_type.addr, align 4
29 store ptr %ip, ptr %ip.addr, align 8
30 %0 = load i32, ptr %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
38 %1 = load i32, ptr %tag_type.addr, align 4
39 %cmp1 = icmp ne i32 %1, 0
40 br i1 %cmp1, label %if.then2, label %if.end
43 %2 = load ptr, ptr %ip.addr, align 8
44 store i8 42, ptr %2, align 1
54 declare i64 @llvm.expect.i64(i64, i64)