File: pr32544.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-20
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,436 kB
  • sloc: cpp: 5,593,990; ansic: 986,873; 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,547; xml: 953; cs: 573; fortran: 567
file content (85 lines) | stat: -rw-r--r-- 2,820 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -O3 -S < %s                    | FileCheck %s
; RUN: opt -passes='default<O3>' -S < %s  | FileCheck %s

define void @foo(i1 %which, i32 %a, i32 %b, i64 *%result) {
; CHECK-LABEL: @foo(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
; CHECK-NEXT:    [[Z_V_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
; CHECK-NEXT:    [[Z_V:%.*]] = add i32 [[Z_V_P]], [[A:%.*]]
; CHECK-NEXT:    [[Z:%.*]] = zext i32 [[Z_V]] to i64
; CHECK-NEXT:    [[C:%.*]] = load i64, i64* [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z]]
; CHECK-NEXT:    store i64 [[VALUE]], i64* [[RESULT]], align 4
; CHECK-NEXT:    ret void
;
entry:
  %x = add i32 %a, %b
  %x2 = zext i32 %x to i64
  br i1 %which, label %final, label %delay

delay:
  %y = sub i32 %a, %b
  %y2 = zext i32 %y to i64
  br label %final

final:
  %z = phi i64 [ %x2, %entry ], [ %y2, %delay ]
  %c = load i64, i64* %result
  %value = add i64 %z, %c
  store i64 %value, i64* %result
  ret void
}

define void @bar(i1 %which, i32 %a, i32 %b, i64 *%result) {
; CHECK-LABEL: @bar(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
; CHECK-NEXT:    [[SPEC_SELECT_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
; CHECK-NEXT:    [[SPEC_SELECT:%.*]] = add i32 [[SPEC_SELECT_P]], [[A:%.*]]
; CHECK-NEXT:    [[Z2:%.*]] = zext i32 [[SPEC_SELECT]] to i64
; CHECK-NEXT:    [[C:%.*]] = load i64, i64* [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z2]]
; CHECK-NEXT:    store i64 [[VALUE]], i64* [[RESULT]], align 4
; CHECK-NEXT:    ret void
;
entry:
  %x = add i32 %a, %b
  br i1 %which, label %final, label %delay

delay:
  %y = sub i32 %a, %b
  br label %final

final:
  %z = phi i32 [ %x, %entry ], [ %y, %delay ]
  %z2 = zext i32 %z to i64
  %c = load i64, i64* %result
  %value = add i64 %z2, %c
  store i64 %value, i64* %result
  ret void
}

define void @foo_opt(i1 %which, i32 %a, i32 %b, i64* nocapture %result) {
; CHECK-LABEL: @foo_opt(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
; CHECK-NEXT:    [[Z_V_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
; CHECK-NEXT:    [[Z_V:%.*]] = add i32 [[Z_V_P]], [[A:%.*]]
; CHECK-NEXT:    [[Z:%.*]] = zext i32 [[Z_V]] to i64
; CHECK-NEXT:    [[C:%.*]] = load i64, i64* [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z]]
; CHECK-NEXT:    store i64 [[VALUE]], i64* [[RESULT]], align 4
; CHECK-NEXT:    ret void
;
entry:
  %0 = sub i32 0, %b
  %z.v.p = select i1 %which, i32 %b, i32 %0
  %z.v = add i32 %z.v.p, %a
  %z = zext i32 %z.v to i64
  %c = load i64, i64* %result, align 4
  %value = add i64 %c, %z
  store i64 %value, i64* %result, align 4
  ret void
}