[InstCombine] Signed saturation patterns
[llvm-core.git] / test / CodeGen / ARM / no_redundant_trunc_for_cmp.ll
blob7146c09ee8096457fbd05c606627b4b198b3626d
1 ; This test check if redundant truncate for eq/ne cmp is skipped during code gen.
2 ;RUN: llc -mtriple=thumbv7-eabi < %s | FileCheck %s
4 define void @test_zero(i16 signext %x) optsize {
5 ;CHECK-LABEL: test_zero
6 entry:
7   %tobool = icmp eq i16 %x, 0
8   br i1 %tobool, label %if.else, label %if.then
9 ;CHECK-NOT: movw {{.*}}, #65535
10 ;CHECK: cbz r0,
11 if.then:                                          ; preds = %entry
12   tail call void bitcast (void (...)* @foo1 to void ()*)()
13   br label %if.end
15 if.else:                                          ; preds = %entry
16   tail call void bitcast (void (...)* @foo2 to void ()*)()
17   br label %if.end
19 if.end:                                           ; preds = %if.else, %if.then
20   ret void
23 define void @test_i8_nonzero(i18 signext %x) optsize {
24 ;CHECK-LABEL: test_i8_nonzero
25 entry:
26   %tobool = icmp eq i18 %x, 150
27   br i1 %tobool, label %if.else, label %if.then
28 ;CHECK-NOT: bfc
29 ;CHECK: cmp r{{[0-9]+}}, #150
30 if.then:                                          ; preds = %entry
31   tail call void bitcast (void (...)* @foo1 to void ()*)()
32   br label %if.end
34 if.else:                                          ; preds = %entry
35   tail call void bitcast (void (...)* @foo2 to void ()*)()
36   br label %if.end
38 if.end:                                           ; preds = %if.else, %if.then
39   ret void
42 define void @test_i8_i16(i8 signext %x) optsize {
43 ;CHECK-LABEL: test_i8_i16
44 entry:
45   %x16 = sext i8 %x to i16
46   %tobool = icmp eq i16 %x16, 300
47   br i1 %tobool, label %if.else, label %if.then
48 ;CHECK-NOT: uxth r0, r0
49 ;CHECK: cmp.w r0, #300
50 if.then:                                          ; preds = %entry
51   tail call void bitcast (void (...)* @foo1 to void ()*)()
52   br label %if.end
54 if.else:                                          ; preds = %entry
55   tail call void bitcast (void (...)* @foo2 to void ()*)()
56   br label %if.end
58 if.end:                                           ; preds = %if.else, %if.then
59   ret void
62 define void @test_i16_i8(i16 signext %x) optsize {
63 ;CHECK-LABEL: test_i16_i8
64 entry:
65 ;CHECK: uxtb [[REG:r[0-9+]]], r0
66 ;CHECK: cmp [[REG]], #128
67   %x8 = trunc i16 %x to i8
68   %tobool = icmp eq i8 %x8, 128
69   br i1 %tobool, label %if.else, label %if.then
70 if.then:                                          ; preds = %entry
71   tail call void bitcast (void (...)* @foo1 to void ()*)()
72   br label %if.end
74 if.else:                                          ; preds = %entry
75   tail call void bitcast (void (...)* @foo2 to void ()*)()
76   br label %if.end
78 if.end:                                           ; preds = %if.else, %if.then
79   ret void
82 define void @test_zext_zero(i16 zeroext %x) optsize {
83 ;CHECK-LABEL: test_zext_zero
84 entry:
85   %tobool = icmp eq i16 %x, 0
86   br i1 %tobool, label %if.else, label %if.then
87 ;CHECK-NOT: movw {{.*}}, #65535
88 ;CHECK: cbz r0,
89 if.then:                                          ; preds = %entry
90   tail call void bitcast (void (...)* @foo1 to void ()*)()
91   br label %if.end
93 if.else:                                          ; preds = %entry
94   tail call void bitcast (void (...)* @foo2 to void ()*)()
95   br label %if.end
97 if.end:                                           ; preds = %if.else, %if.then
98   ret void
102 declare void @foo1(...)
103 declare void @foo2(...)