File: pr32544.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (85 lines) | stat: -rw-r--r-- 2,805 bytes parent folder | download | duplicates (5)
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, ptr %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, ptr [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z]]
; CHECK-NEXT:    store i64 [[VALUE]], ptr [[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, ptr %result
  %value = add i64 %z, %c
  store i64 %value, ptr %result
  ret void
}

define void @bar(i1 %which, i32 %a, i32 %b, ptr %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, ptr [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z2]]
; CHECK-NEXT:    store i64 [[VALUE]], ptr [[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, ptr %result
  %value = add i64 %z2, %c
  store i64 %value, ptr %result
  ret void
}

define void @foo_opt(i1 %which, i32 %a, i32 %b, ptr 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, ptr [[RESULT:%.*]], align 4
; CHECK-NEXT:    [[VALUE:%.*]] = add i64 [[C]], [[Z]]
; CHECK-NEXT:    store i64 [[VALUE]], ptr [[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, ptr %result, align 4
  %value = add i64 %c, %z
  store i64 %value, ptr %result, align 4
  ret void
}