File: branch-on-argument.ll

package info (click to toggle)
llvm-toolchain-5.0 1:5.0.1-2~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 553,688 kB
  • sloc: cpp: 2,878,786; ansic: 584,110; asm: 246,252; python: 124,751; objc: 106,925; sh: 21,542; lisp: 8,628; pascal: 5,885; ml: 5,544; perl: 5,312; makefile: 2,208; cs: 2,022; xml: 686; php: 212; csh: 117
file content (47 lines) | stat: -rw-r--r-- 1,264 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
; RUN: opt -S -o - -structurizecfg < %s | FileCheck %s

; CHECK-LABEL: @invert_branch_on_arg_inf_loop(
; CHECK: entry:
; CHECK: %arg.inv = xor i1 %arg, true
; CHECK: phi i1 [ false, %Flow1 ], [ %arg.inv, %entry ]
define void @invert_branch_on_arg_inf_loop(i32 addrspace(1)* %out, i1 %arg) {
entry:
  br i1 %arg, label %for.end, label %for.body

for.body:                                         ; preds = %entry, %for.body
  store i32 999, i32 addrspace(1)* %out, align 4
  br label %for.body

for.end:                                          ; preds = %Flow
  ret void
}


; CHECK-LABEL: @invert_branch_on_arg_jump_into_loop(
; CHECK: entry:
; CHECK: %arg.inv = xor i1 %arg, true
; CHECK: Flow:
; CHECK: Flow1:
define void @invert_branch_on_arg_jump_into_loop(i32 addrspace(1)* %out, i32 %n, i1 %arg) {
entry:
  br label %for.body

for.body:
  %i = phi i32 [0, %entry], [%i.inc, %end.loop]
  %ptr = getelementptr i32, i32 addrspace(1)* %out, i32 %i
  store i32 %i, i32 addrspace(1)* %ptr, align 4
  br i1 %arg, label %mid.loop, label %end.loop

mid.loop:
  store i32 333, i32 addrspace(1)* %out, align 4
  br label %for.end

end.loop:
  %i.inc = add i32 %i, 1
  %cmp = icmp ne i32 %i.inc, %n
  br i1 %cmp, label %for.body, label %for.end

for.end:
  ret void
}