1 ; RUN: llc -mtriple=thumbv7m -arm-disable-cgp=false %s -o - | FileCheck %s --check-prefix=CHECK-COMMON
2 ; RUN: llc -mtriple=thumbv8m.main -arm-disable-cgp=false %s -o - | FileCheck %s --check-prefix=CHECK-COMMON
3 ; RUN: llc -mtriple=thumbv8m.main -arm-disable-cgp=false -arm-enable-scalar-dsp=true -mcpu=cortex-m33 %s -o - | FileCheck %s --check-prefix=CHECK-COMMON
4 ; RUN: llc -mtriple=thumbv7em %s -arm-disable-cgp=false -arm-enable-scalar-dsp=true -arm-enable-scalar-dsp-imms=true -o - | FileCheck %s --check-prefix=CHECK-COMMON
6 ; Test that ARMCodeGenPrepare can handle:
11 ; We use nuw on the arithmetic instructions to avoid complications.
13 ; Check that the arguments are extended but then nothing else is.
14 ; This also ensures that the pass can handle loops.
15 ; CHECK-COMMON-LABEL: phi_feeding_phi_args
19 define void @phi_feeding_phi_args(i8 %a, i8 %b) {
21 %0 = icmp ugt i8 %a, %b
22 br i1 %0, label %preheader, label %empty
28 %1 = phi i8 [ %a, %entry ], [ %b, %empty ]
32 %val = phi i8 [ %1, %preheader ], [ %inc2, %if.end ]
33 %cmp = icmp ult i8 %val, 254
34 br i1 %cmp, label %if.then, label %if.else
37 %inc = sub nuw i8 %val, 2
41 %inc1 = shl nuw i8 %val, 1
45 %inc2 = phi i8 [ %inc, %if.then], [ %inc1, %if.else ]
46 %cmp1 = icmp eq i8 %inc2, 255
47 br i1 %cmp1, label %exit, label %loop
53 ; Same as above, but as the args are zeroext, we shouldn't see any uxts.
54 ; CHECK-COMMON-LABEL: phi_feeding_phi_zeroext_args
55 ; CHECK-COMMON-NOT: uxt
56 define void @phi_feeding_phi_zeroext_args(i8 zeroext %a, i8 zeroext %b) {
58 %0 = icmp ugt i8 %a, %b
59 br i1 %0, label %preheader, label %empty
65 %1 = phi i8 [ %a, %entry ], [ %b, %empty ]
69 %val = phi i8 [ %1, %preheader ], [ %inc2, %if.end ]
70 %cmp = icmp ult i8 %val, 254
71 br i1 %cmp, label %if.then, label %if.else
74 %inc = sub nuw i8 %val, 2
78 %inc1 = shl nuw i8 %val, 1
82 %inc2 = phi i8 [ %inc, %if.then], [ %inc1, %if.else ]
83 %cmp1 = icmp eq i8 %inc2, 255
84 br i1 %cmp1, label %exit, label %loop
90 ; Just check that phis also work with i16s.
91 ; CHECK-COMMON-LABEL: phi_i16:
92 ; CHECK-COMMON-NOT: uxt
93 define void @phi_i16() {
98 %val = phi i16 [ 0, %entry ], [ %inc2, %if.end ]
99 %cmp = icmp ult i16 %val, 128
100 br i1 %cmp, label %if.then, label %if.else
103 %inc = add nuw i16 %val, 2
107 %inc1 = add nuw i16 %val, 1
111 %inc2 = phi i16 [ %inc, %if.then], [ %inc1, %if.else ]
112 %cmp1 = icmp ult i16 %inc2, 253
113 br i1 %cmp1, label %loop, label %exit
119 ; CHECK-COMMON-LABEL: ret_i8
120 ; CHECK-COMMON-NOT: uxt
121 define i8 @ret_i8() {
126 %val = phi i8 [ 0, %entry ], [ %inc2, %if.end ]
127 %cmp = icmp ult i8 %val, 128
128 br i1 %cmp, label %if.then, label %if.else
131 %inc = add nuw i8 %val, 2
135 %inc1 = add nuw i8 %val, 1
139 %inc2 = phi i8 [ %inc, %if.then], [ %inc1, %if.else ]
140 %cmp1 = icmp ult i8 %inc2, 253
141 br i1 %cmp1, label %exit, label %loop
147 ; CHECK-COMMON-LABEL: phi_multiple_undefs
148 ; CHECK-COMMON-NOT: uxt
149 define i16 @phi_multiple_undefs(i16 zeroext %arg) {
154 %val = phi i16 [ undef, %entry ], [ %inc2, %if.end ]
155 %cmp = icmp ult i16 %val, 128
156 br i1 %cmp, label %if.then, label %if.else
159 %inc = add nuw i16 %val, 2
163 %inc1 = add nuw i16 %val, 1
167 %inc2 = phi i16 [ %inc, %if.then], [ %inc1, %if.else ]
168 %unrelated = phi i16 [ undef, %if.then ], [ %arg, %if.else ]
169 %cmp1 = icmp ult i16 %inc2, 253
170 br i1 %cmp1, label %loop, label %exit
176 ; CHECK-COMMON-LABEL: promote_arg_return
177 ; CHECK-COMMON-NOT: uxt
179 define i16 @promote_arg_return(i16 zeroext %arg1, i16 zeroext %arg2, i8* %res) {
180 %add = add nuw i16 %arg1, 15
181 %mul = mul nuw nsw i16 %add, 3
182 %cmp = icmp ult i16 %mul, %arg2
183 %conv = zext i1 %cmp to i8
184 store i8 %conv, i8* %res