reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
; RUN: opt -correlated-propagation -S < %s | FileCheck %s

declare void @llvm.experimental.guard(i1,...)

define i1 @test1(i32 %a) {
; CHECK-LABEL: @test1(
; CHECK: %alive = icmp eq i32 %a, 8
; CHECK-NEXT: %result = or i1 false, %alive
  %cmp = icmp ult i32 %a, 16
  call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
  %dead = icmp eq i32 %a, 16
  %alive = icmp eq i32 %a, 8
  %result = or i1 %dead, %alive
  ret i1 %result
}

define i1 @test2(i32 %a) {
; CHECK-LABEL: @test2(
; CHECK: continue:
; CHECK-NEXT: %alive = icmp eq i32 %a, 8
; CHECK-NEXT: %result = or i1 false, %alive
  %cmp = icmp ult i32 %a, 16
  call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
  br label %continue

continue:
  %dead = icmp eq i32 %a, 16
  %alive = icmp eq i32 %a, 8
  %result = or i1 %dead, %alive
  ret i1 %result
}

define i1 @test3(i32 %a, i1 %flag) {
; CHECK-LABEL: @test3(
; CHECK: continue:
; CHECK-NEXT: %alive.1 = icmp eq i32 %a, 16
; CHECK-NEXT: %alive.2 = icmp eq i32 %a, 8
; CHECK-NEXT: %result = or i1 %alive.1, %alive.2
  br i1 %flag, label %true, label %false

true:
  %cmp = icmp ult i32 %a, 16
  call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
  br label %continue

false:
  br label %continue

continue:
  %alive.1 = icmp eq i32 %a, 16
  %alive.2 = icmp eq i32 %a, 8
  %result = or i1 %alive.1, %alive.2
  ret i1 %result
}

define i1 @test4(i32 %a, i1 %flag) {
; CHECK-LABEL: @test4(
; CHECK: continue:
; CHECK-NEXT: %alive = icmp eq i32 %a, 12
; CHECK-NEXT: %result = or i1 false, %alive
  br i1 %flag, label %true, label %false

true:
  %cmp.t = icmp ult i32 %a, 16
  call void(i1,...) @llvm.experimental.guard(i1 %cmp.t) [ "deopt"() ]
  br label %continue

false:
  %cmp.f = icmp ult i32 %a, 12
  call void(i1,...) @llvm.experimental.guard(i1 %cmp.f) [ "deopt"() ]
  br label %continue

continue:
  %dead = icmp eq i32 %a, 16
  %alive = icmp eq i32 %a, 12
  %result = or i1 %dead, %alive
  ret i1 %result
}

define i1 @test5(i32 %a) {
; CHECK-LABEL: @test5(
; CHECK: continue:
; CHECK-NEXT: %alive = icmp eq i32 %a.plus.8, 16
; CHECK-NEXT: %result = or i1 false, %alive
  %cmp = icmp ult i32 %a, 16
  call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
  %a.plus.8 = add i32 %a, 8
  br label %continue

continue:
  %dead = icmp eq i32 %a.plus.8, 24
  %alive = icmp eq i32 %a.plus.8, 16
  %result = or i1 %dead, %alive
  ret i1 %result
}

; Check that we handle the case when the guard is the very first instruction in
; a basic block.
define i1 @test6(i32 %a) {
; CHECK-LABEL: @test6(
; CHECK: %alive = icmp eq i32 %a, 8
; CHECK-NEXT: %result = or i1 false, %alive
  %cmp = icmp ult i32 %a, 16
  br label %continue

continue:
  call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
  %dead = icmp eq i32 %a, 16
  %alive = icmp eq i32 %a, 8
  %result = or i1 %dead, %alive
  ret i1 %result
}