summaryrefslogtreecommitdiff
path: root/test/CodeGen/Thumb/cmp-fold.ll
blob: a278e4321d030855c83f2b6f4cc46c1a6f274b04 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
; RUN: llc -mtriple=thumbv6m-eabi -verify-machineinstrs < %s | FileCheck %s

; CHECK-LABEL: subs:
; CHECK: subs
; CHECK-NEXT: b{{eq|ne}}
define i32 @subs(i32 %a, i32 %b) {
  %c = sub i32 %a, %b
  %d = icmp eq i32 %c, 0
  br i1 %d, label %true, label %false

true:
  ret i32 4
false:
  ret i32 5
}

; CHECK-LABEL: addsrr:
; CHECK: adds
; CHECK-NEXT: b{{eq|ne}}
define i32 @addsrr(i32 %a, i32 %b) {
  %c = add i32 %a, %b
  %d = icmp eq i32 %c, 0
  br i1 %d, label %true, label %false

true:
  ret i32 4
false:
  ret i32 5
}

; CHECK-LABEL: lslri:
; CHECK: lsls
; CHECK-NEXT: b{{eq|ne}}
define i32 @lslri(i32 %a, i32 %b) {
  %c = shl i32 %a, 3
  %d = icmp eq i32 %c, 0
  br i1 %d, label %true, label %false

true:
  ret i32 4
false:
  ret i32 5
}

; CHECK-LABEL: lslrr:
; CHECK: lsls
; CHECK-NEXT: b{{eq|ne}}
define i32 @lslrr(i32 %a, i32 %b) {
  %c = shl i32 %a, %b
  %d = icmp eq i32 %c, 0
  br i1 %d, label %true, label %false

true:
  ret i32 4
false:
  ret i32 5
}