aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/canonicalize_branch.ll
blob: 24090abcb5acd3f96c51c4f613a4b9361666e649 (plain)
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
; RUN: opt < %s -instcombine -S | FileCheck %s

define i32 @test1(i32 %X, i32 %Y) {
        %C = icmp ne i32 %X, %Y
        br i1 %C, label %T, label %F

; CHECK: @test1
; CHECK: %C = icmp eq i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T

T:
        ret i32 12
F:
        ret i32 123
}

define i32 @test2(i32 %X, i32 %Y) {
        %C = icmp ule i32 %X, %Y
        br i1 %C, label %T, label %F

; CHECK: @test2
; CHECK: %C = icmp ugt i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T

T:
        ret i32 12
F:
        ret i32 123
}

define i32 @test3(i32 %X, i32 %Y) {
        %C = icmp uge i32 %X, %Y
        br i1 %C, label %T, label %F

; CHECK: @test3
; CHECK: %C = icmp ult i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T

T:
        ret i32 12
F:
        ret i32 123
}