File: no_redundant_trunc_for_cmp.ll

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (105 lines) | stat: -rw-r--r-- 3,240 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
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
; This test check if redundant truncate for eq/ne cmp is skipped during code gen.
;RUN: llc -mtriple=thumbv7-eabi < %s | FileCheck %s

define void @test_zero(i16 signext %x) optsize {
;CHECK-LABEL: test_zero
entry:
  %tobool = icmp eq i16 %x, 0
  br i1 %tobool, label %if.else, label %if.then
;CHECK-NOT: movw {{.*}}, #65535
;CHECK: cbz r0,
if.then:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo1 to void ()*)()
  br label %if.end

if.else:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo2 to void ()*)()
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

define void @test_i8_nonzero(i18 signext %x) optsize {
;CHECK-LABEL: test_i8_nonzero
entry:
  %tobool = icmp eq i18 %x, 150
  br i1 %tobool, label %if.else, label %if.then
;CHECK-NOT: bfc
;CHECK: cmp r{{[0-9]+}}, #150
if.then:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo1 to void ()*)()
  br label %if.end

if.else:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo2 to void ()*)()
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

define void @test_i8_i16(i8 signext %x) optsize {
;CHECK-LABEL: test_i8_i16
entry:
  %x16 = sext i8 %x to i16
  %tobool = icmp eq i16 %x16, 300
  br i1 %tobool, label %if.else, label %if.then
;CHECK-NOT: uxth r0, r0
;CHECK: cmp.w r0, #300
if.then:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo1 to void ()*)()
  br label %if.end

if.else:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo2 to void ()*)()
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

define void @test_i16_i8(i16 signext %x) optsize {
;CHECK-LABEL: test_i16_i8
entry:
;CHECK: uxtb [[REG:r[0-9+]]], r0
;CHECK: cmp [[REG]], #128
  %x8 = trunc i16 %x to i8
  %tobool = icmp eq i8 %x8, 128
  br i1 %tobool, label %if.else, label %if.then
if.then:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo1 to void ()*)()
  br label %if.end

if.else:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo2 to void ()*)()
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}

define void @test_zext_zero(i16 zeroext %x) optsize {
;CHECK-LABEL: test_zext_zero
entry:
  %tobool = icmp eq i16 %x, 0
  br i1 %tobool, label %if.else, label %if.then
;CHECK-NOT: movw {{.*}}, #65535
;CHECK: cbz r0,
if.then:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo1 to void ()*)()
  br label %if.end

if.else:                                          ; preds = %entry
  tail call void bitcast (void (...)* @foo2 to void ()*)()
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  ret void
}


declare void @foo1(...)
declare void @foo2(...)