1 /* Check that sign/zero extensions are emitted where needed when the
2    tst Rm,Rn instruction is used.  */
3 /* { dg-do compile }  */
4 /* { dg-options "-O1" }  */
5 /* { dg-final { scan-assembler-times "tst\tr" 8 } }  */
6 /* { dg-final { scan-assembler-times "mov.b" 4 } }  */
7 /* { dg-final { scan-assembler-times "mov.w" 4 } }  */
8 /* { dg-final { scan-assembler-times "extu.b" 4 } }  */
9 /* { dg-final { scan-assembler-times "extu.w" 2 } }  */
10 
11 int
test_00(char * x,char * y)12 test_00 (char* x, char* y)
13 {
14   /* 2x mov.b (sign extending)  */
15   return *x & *y ? -40 : 60;
16 }
17 
18 int
test_01(short * x,short * y)19 test_01 (short* x, short* y)
20 {
21   /* 2x mov.w (sign extending)  */
22   return *x & *y ? -40 : 60;
23 }
24 
25 int
test_02(char x,char y)26 test_02 (char x, char y)
27 {
28   /* 1x extu.b  */
29   return x & y ? -40 : 60;
30 }
31 
32 int
test_03(short x,short y)33 test_03 (short x, short y)
34 {
35   /* 1x extu.w  */
36   return x & y ? -40 : 60;
37 }
38 
39 int
test_04(char * x,unsigned char y)40 test_04 (char* x, unsigned char y)
41 {
42   /* 1x mov.b, 1x extu.b  */
43   return *x & y ? -40 : 60;
44 }
45 
46 int
test_05(short * x,unsigned char y)47 test_05 (short* x, unsigned char y)
48 {
49   /* 1x mov.w, 1x extu.b  */
50   return *x & y ? -40 : 60;
51 }
52 
53 int
test_06(short x,short * y,int z,int w)54 test_06 (short x, short* y, int z, int w)
55 {
56   /* 1x mov.w, 1x extu.w  */
57   return x & y[0] ? z : w;
58 }
59 
60 int
test_07(char x,char * y,int z,int w)61 test_07 (char x, char* y, int z, int w)
62 {
63   /* 1x mov.b, 1x extu.b  */
64   return x & y[0] ? z : w;
65 }
66