File: callbr-edge-split.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (56 lines) | stat: -rw-r--r-- 1,930 bytes parent folder | download | duplicates (12)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -passes=jump-threading | FileCheck %s

; This test used to cause jump threading to try to split an edge of a callbr.

@a = global i32 0

define i32 @c() {
; CHECK-LABEL: @c(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr @a, align 4
; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
; CHECK:       if.else:
; CHECK-NEXT:    callbr void asm sideeffect "", "!i"()
; CHECK-NEXT:    to label [[IF_THEN2:%.*]] [label %if.then2]
; CHECK:       if.end:
; CHECK-NEXT:    [[CALL:%.*]] = call i32 @b()
; CHECK-NEXT:    [[PHITMP:%.*]] = icmp ne i32 [[CALL]], 0
; CHECK-NEXT:    br i1 [[PHITMP]], label [[IF_THEN2]], label [[IF_END4:%.*]]
; CHECK:       if.then2:
; CHECK-NEXT:    [[CALL3:%.*]] = call i32 @b()
; CHECK-NEXT:    br label [[IF_END4]]
; CHECK:       if.end4:
; CHECK-NEXT:    ret i32 undef
;
entry:
  %0 = load i32, ptr @a
  %tobool = icmp eq i32 %0, 0
  br i1 %tobool, label %if.else, label %if.then

if.then:                                          ; preds = %entry
  %call = call i32 @b() #2
  %phitmp = icmp ne i32 %call, 0
  br label %if.end

if.else:                                          ; preds = %entry
  callbr void asm sideeffect "", "!i"() #2
  to label %normal [label %if.end]

normal:                                           ; preds = %if.else
  br label %if.end

if.end:                                           ; preds = %if.else, %normal, %if.then
  %d.0 = phi i1 [ %phitmp, %if.then ], [ undef, %normal ], [ undef, %if.else ]
  br i1 %d.0, label %if.then2, label %if.end4

if.then2:                                         ; preds = %if.end
  %call3 = call i32 @b()
  br label %if.end4

if.end4:                                          ; preds = %if.then2, %if.end
  ret i32 undef
}

declare i32 @b()