]>
Commit | Line | Data |
---|---|---|
96023bba AV |
1 | /* Test division by const int generates only one shift. */ |
2 | /* { dg-do run } */ | |
3 | /* { dg-options "-O2 -fdump-rtl-combine-all" } */ | |
4 | ||
5 | extern void abort (void); | |
6 | ||
7 | #define NOINLINE __attribute__((noinline)) | |
8 | ||
9 | static NOINLINE int | |
10 | f1 (int n) | |
11 | { | |
12 | return n / 33; | |
13 | } | |
14 | ||
15 | static NOINLINE int | |
16 | f2 (int n) | |
17 | { | |
18 | return n / 77; | |
19 | } | |
20 | ||
21 | int | |
22 | main () | |
23 | { | |
24 | int a = 0xaaaaaaaa; | |
25 | int b = 0x55555555; | |
26 | int c; | |
27 | c = f1 (a); | |
28 | if (c != 0xfd6a052c) | |
29 | abort (); | |
30 | c = f1 (b); | |
31 | if (c != 0x295FAD4) | |
32 | abort (); | |
33 | c = f2 (a); | |
34 | if (c != 0xfee44b5c) | |
35 | abort (); | |
36 | c = f2 (b); | |
37 | if (c != 0x11bb4a4) | |
38 | abort (); | |
39 | return 0; | |
40 | } | |
41 | ||
42 | /* Following replacement pattern of intger division by constant, GCC is expected | |
43 | to generate MULT and (x)SHIFTRT. This test checks that considering division | |
44 | by const 33, gcc generates a single ASHIFTRT by 35, instead of two - LSHIFTRT | |
45 | by 32 and ASHIFTRT by 3. */ | |
46 | ||
47 | /* { dg-final { scan-rtl-dump "\\(set \\(subreg:DI \\(reg:SI" "combine" { target aarch64*-*-* } } } */ | |
48 | /* { dg-final { scan-rtl-dump "\\(ashiftrt:DI \\(reg:DI" "combine" { target aarch64*-*-* } } } */ | |
49 | /* { dg-final { scan-rtl-dump "\\(const_int 35 " "combine" { target aarch64*-*-* } } } */ | |
50 | ||
51 | /* Similarly, considering division by const 77, gcc generates a single ASHIFTRT | |
52 | by 36, instead of two - LSHIFTRT by 32 and ASHIFTRT by 4. */ | |
53 | ||
54 | /* { dg-final { scan-rtl-dump "\\(const_int 36 " "combine" { target aarch64*-*-* } } } */ | |
55 |