File: hoist-nounwind.ll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (97 lines) | stat: -rw-r--r-- 2,766 bytes parent folder | download | duplicates (14)
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
86
87
88
89
90
91
92
93
94
95
96
97
; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop-mssa(licm)' -S %s | FileCheck %s
; RUN: opt -S -passes=licm -verify-memoryssa < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare void @f() nounwind

; Don't hoist load past nounwind call.
define i32 @test1(ptr noalias nocapture readonly %a) nounwind uwtable {
; CHECK-LABEL: @test1(
entry:
  br label %for.body

; CHECK: tail call void @f()
; CHECK-NEXT: load i32
for.body:
  %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  tail call void @f() nounwind
  %i1 = load i32, ptr %a, align 4
  %add = add nsw i32 %i1, %x.05
  %inc = add nuw nsw i32 %i.06, 1
  %exitcond = icmp eq i32 %inc, 1000
  br i1 %exitcond, label %for.cond.cleanup, label %for.body

for.cond.cleanup:
  ret i32 %add
}

; Don't hoist division past nounwind call.
define i32 @test2(i32 %N, i32 %c) nounwind uwtable {
; CHECK-LABEL: @test2(
entry:
  %cmp4 = icmp sgt i32 %N, 0
  br i1 %cmp4, label %for.body, label %for.cond.cleanup

; CHECK: tail call void @f()
; CHECK-NEXT: sdiv i32
for.body:
  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
  tail call void @f() nounwind
  %div = sdiv i32 5, %c
  %add = add i32 %i.05, 1
  %inc = add i32 %add, %div
  %cmp = icmp slt i32 %inc, %N
  br i1 %cmp, label %for.body, label %for.cond.cleanup

for.cond.cleanup:
  ret i32 0
}

; Hoist a non-volatile load past volatile load.
define i32 @test3(ptr noalias nocapture readonly %a, ptr %v) nounwind uwtable {
; CHECK-LABEL: @test3(
entry:
  br label %for.body

; CHECK: load i32
; CHECK: for.body:
; CHECK: load volatile i32
; CHECK-NOT: load
for.body:
  %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %xxx = load volatile i32, ptr %v, align 4
  %i1 = load i32, ptr %a, align 4
  %add = add nsw i32 %i1, %x.05
  %inc = add nuw nsw i32 %i.06, 1
  %exitcond = icmp eq i32 %inc, 1000
  br i1 %exitcond, label %for.cond.cleanup, label %for.body

for.cond.cleanup:
  ret i32 %add
}

; Don't a volatile load past volatile load.
define i32 @test4(ptr noalias nocapture readonly %a, ptr %v) nounwind uwtable {
; CHECK-LABEL: @test4(
entry:
  br label %for.body

; CHECK: for.body:
; CHECK: load volatile i32
; CHECK-NEXT: load volatile i32
for.body:
  %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %x.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %xxx = load volatile i32, ptr %v, align 4
  %i1 = load volatile i32, ptr %a, align 4
  %add = add nsw i32 %i1, %x.05
  %inc = add nuw nsw i32 %i.06, 1
  %exitcond = icmp eq i32 %inc, 1000
  br i1 %exitcond, label %for.cond.cleanup, label %for.body

for.cond.cleanup:
  ret i32 %add
}