| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 --save-temps -fno-inline" } */ |
| 3 |
|
| 4 |
extern void abort (void); |
| 5 |
|
| 6 |
int |
| 7 |
adds_si_test1 (int a, int b, int c) |
| 8 |
{ |
| 9 |
int d = a + b; |
| 10 |
|
| 11 |
/* { dg-final { scan-assembler-not "adds\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */ |
| 12 |
/* { dg-final { scan-assembler "add\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */ |
| 13 |
if (d <= 0) |
| 14 |
return a + c; |
| 15 |
else |
| 16 |
return b + d + c; |
| 17 |
} |
| 18 |
|
| 19 |
int |
| 20 |
adds_si_test2 (int a, int b, int c) |
| 21 |
{ |
| 22 |
int d = a + 0xfff; |
| 23 |
|
| 24 |
/* { dg-final { scan-assembler-not "adds\tw\[0-9\]+, w\[0-9\]+, 4095" } } */ |
| 25 |
/* { dg-final { scan-assembler "add\tw\[0-9\]+, w\[0-9\]+, 4095" } } */ |
| 26 |
if (d <= 0) |
| 27 |
return a + c; |
| 28 |
else |
| 29 |
return b + d + c; |
| 30 |
} |
| 31 |
|
| 32 |
int |
| 33 |
adds_si_test3 (int a, int b, int c) |
| 34 |
{ |
| 35 |
int d = a + (b << 3); |
| 36 |
|
| 37 |
/* { dg-final { scan-assembler-not "adds\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ |
| 38 |
/* { dg-final { scan-assembler "add\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ |
| 39 |
if (d <= 0) |
| 40 |
return a + c; |
| 41 |
else |
| 42 |
return b + d + c; |
| 43 |
} |
| 44 |
|
| 45 |
typedef long long s64; |
| 46 |
|
| 47 |
s64 |
| 48 |
adds_di_test1 (s64 a, s64 b, s64 c) |
| 49 |
{ |
| 50 |
s64 d = a + b; |
| 51 |
|
| 52 |
/* { dg-final { scan-assembler-not "adds\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */ |
| 53 |
/* { dg-final { scan-assembler "add\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */ |
| 54 |
if (d <= 0) |
| 55 |
return a + c; |
| 56 |
else |
| 57 |
return b + d + c; |
| 58 |
} |
| 59 |
|
| 60 |
s64 |
| 61 |
adds_di_test2 (s64 a, s64 b, s64 c) |
| 62 |
{ |
| 63 |
s64 d = a + 0x1000ll; |
| 64 |
|
| 65 |
/* { dg-final { scan-assembler-not "adds\tx\[0-9\]+, x\[0-9\]+, 4096" } } */ |
| 66 |
/* { dg-final { scan-assembler "add\tx\[0-9\]+, x\[0-9\]+, 4096" } } */ |
| 67 |
if (d <= 0) |
| 68 |
return a + c; |
| 69 |
else |
| 70 |
return b + d + c; |
| 71 |
} |
| 72 |
|
| 73 |
s64 |
| 74 |
adds_di_test3 (s64 a, s64 b, s64 c) |
| 75 |
{ |
| 76 |
s64 d = a + (b << 3); |
| 77 |
|
| 78 |
/* { dg-final { scan-assembler-not "adds\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ |
| 79 |
/* { dg-final { scan-assembler "add\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ |
| 80 |
if (d <= 0) |
| 81 |
return a + c; |
| 82 |
else |
| 83 |
return b + d + c; |
| 84 |
} |
| 85 |
|
| 86 |
int main () |
| 87 |
{ |
| 88 |
int x; |
| 89 |
s64 y; |
| 90 |
|
| 91 |
x = adds_si_test1 (29, 4, 5); |
| 92 |
if (x != 42) |
| 93 |
abort (); |
| 94 |
|
| 95 |
x = adds_si_test1 (5, 2, 20); |
| 96 |
if (x != 29) |
| 97 |
abort (); |
| 98 |
|
| 99 |
x = adds_si_test2 (29, 4, 5); |
| 100 |
if (x != 4133) |
| 101 |
abort (); |
| 102 |
|
| 103 |
x = adds_si_test2 (1024, 2, 20); |
| 104 |
if (x != 5141) |
| 105 |
abort (); |
| 106 |
|
| 107 |
x = adds_si_test3 (35, 4, 5); |
| 108 |
if (x != 76) |
| 109 |
abort (); |
| 110 |
|
| 111 |
x = adds_si_test3 (5, 2, 20); |
| 112 |
if (x != 43) |
| 113 |
abort (); |
| 114 |
|
| 115 |
y = adds_di_test1 (0x130000029ll, |
| 116 |
0x320000004ll, |
| 117 |
0x505050505ll); |
| 118 |
|
| 119 |
if (y != 0xc75050536) |
| 120 |
abort (); |
| 121 |
|
| 122 |
y = adds_di_test1 (0x5000500050005ll, |
| 123 |
0x2111211121112ll, |
| 124 |
0x0000000002020ll); |
| 125 |
if (y != 0x9222922294249) |
| 126 |
abort (); |
| 127 |
|
| 128 |
y = adds_di_test2 (0x130000029ll, |
| 129 |
0x320000004ll, |
| 130 |
0x505050505ll); |
| 131 |
if (y != 0x955051532) |
| 132 |
abort (); |
| 133 |
|
| 134 |
y = adds_di_test2 (0x540004100ll, |
| 135 |
0x320000004ll, |
| 136 |
0x805050205ll); |
| 137 |
if (y != 0x1065055309) |
| 138 |
abort (); |
| 139 |
|
| 140 |
y = adds_di_test3 (0x130000029ll, |
| 141 |
0x064000008ll, |
| 142 |
0x505050505ll); |
| 143 |
if (y != 0x9b9050576) |
| 144 |
abort (); |
| 145 |
|
| 146 |
y = adds_di_test3 (0x130002900ll, |
| 147 |
0x088000008ll, |
| 148 |
0x505050505ll); |
| 149 |
if (y != 0xafd052e4d) |
| 150 |
abort (); |
| 151 |
|
| 152 |
return 0; |
| 153 |
} |
| 154 |
|