File: expect.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (54 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -O2 -S < %s | FileCheck %s

; Given an "expect" on a compare, we should not combine
; that compare with other instructions in a way that the
; backend can't undo. Expect lowering becomes metadata,
; and passes like SimplifyCFG should respect that.

define void @PR49336(i32 %delta, i32 %tag_type, i8* %ip) {
; CHECK-LABEL: @PR49336(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[DELTA:%.*]], 0
; CHECK-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END3:%.*]], !prof !0
; CHECK:       if.then:
; CHECK-NEXT:    [[CMP1_NOT:%.*]] = icmp eq i32 [[TAG_TYPE:%.*]], 0
; CHECK-NEXT:    br i1 [[CMP1_NOT]], label [[IF_END3]], label [[IF_THEN2:%.*]]
; CHECK:       if.then2:
; CHECK-NEXT:    store i8 42, i8* [[IP:%.*]], align 1
; CHECK-NEXT:    br label [[IF_END3]]
; CHECK:       if.end3:
; CHECK-NEXT:    ret void
;
entry:
  %delta.addr = alloca i32, align 4
  %tag_type.addr = alloca i32, align 4
  %ip.addr = alloca i8*, align 8
  store i32 %delta, i32* %delta.addr, align 4
  store i32 %tag_type, i32* %tag_type.addr, align 4
  store i8* %ip, i8** %ip.addr, align 8
  %0 = load i32, i32* %delta.addr, align 4
  %cmp = icmp slt i32 %0, 0
  %conv = zext i1 %cmp to i64
  %expval = call i64 @llvm.expect.i64(i64 %conv, i64 0)
  %tobool = icmp ne i64 %expval, 0
  br i1 %tobool, label %if.then, label %if.end3

if.then:
  %1 = load i32, i32* %tag_type.addr, align 4
  %cmp1 = icmp ne i32 %1, 0
  br i1 %cmp1, label %if.then2, label %if.end

if.then2:
  %2 = load i8*, i8** %ip.addr, align 8
  store i8 42, i8* %2, align 1
  br label %if.end

if.end:
  br label %if.end3

if.end3:
  ret void
}

declare i64 @llvm.expect.i64(i64, i64)