Home | History | Annotate | Download | only in CorrelatedValuePropagation
      1 ; RUN: opt -correlated-propagation -S < %s | FileCheck %s
      2 ; Checks that we don't crash on conflicting facts about a value 
      3 ; (i.e. unreachable code)
      4 
      5 ; Test that we can handle conflict edge facts
      6 define i8 @test(i8 %a) {
      7 ; CHECK-LABEL: @test
      8   %cmp1 = icmp eq i8 %a, 5
      9   br i1 %cmp1, label %next, label %exit
     10 next:
     11   %cmp2 = icmp eq i8 %a, 3
     12 ; CHECK: br i1 false, label %dead, label %exit
     13   br i1 %cmp2, label %dead, label %exit
     14 dead:
     15 ; CHECK-LABEL: dead:
     16 ; CHECK: ret i8 5
     17 ; NOTE: undef, or 3 would be equal valid
     18   ret i8 %a
     19 exit:
     20   ret i8 0
     21 }
     22 
     23 declare void @llvm.assume(i1)
     24 
     25 ; Test that we can handle conflicting assume vs edge facts
     26 define i8 @test2(i8 %a) {
     27 ; CHECK-LABEL: @test2
     28   %cmp1 = icmp eq i8 %a, 5
     29   call void @llvm.assume(i1 %cmp1)
     30   %cmp2 = icmp eq i8 %a, 3
     31 ; CHECK: br i1 false, label %dead, label %exit
     32   br i1 %cmp2, label %dead, label %exit
     33 dead:
     34   ret i8 %a
     35 exit:
     36   ret i8 0
     37 }
     38 
     39 define i8 @test3(i8 %a) {
     40 ; CHECK-LABEL: @test3
     41   %cmp1 = icmp eq i8 %a, 5
     42   br i1 %cmp1, label %dead, label %exit
     43 dead:
     44   %cmp2 = icmp eq i8 %a, 3
     45 ; CHECK: call void @llvm.assume(i1 false)
     46   call void @llvm.assume(i1 %cmp2)
     47   ret i8 %a
     48 exit:
     49   ret i8 0
     50 }
     51