| 1 |
/* { dg-do compile { target powerpc*-*-linux* } } */ |
| 2 |
/* { dg-options "-O2 -mregnames" } */ |
| 3 |
/* { dg-require-effective-target has_arch_ppc64 } */ |
| 4 |
|
| 5 |
/* Following instruction sequence is found in assembly of |
| 6 |
Perl_block_start, which is a function of op.c in SPEC2017 |
| 7 |
perlbench. It can be never combined to a move and compare |
| 8 |
instruction in combine pass. A peephole pattern is needed to |
| 9 |
converted the sequence to a "mr." instruction. |
| 10 |
|
| 11 |
cmpdi 0,9,0 |
| 12 |
mr 12,9 |
| 13 |
|
| 14 |
This test case is an analogue of the source code and verifies |
| 15 |
if the peephole2 patterns work. |
| 16 |
*/ |
| 17 |
|
| 18 |
int __RTL (startwith ("peephole2")) compare_move_peephole () |
| 19 |
{ |
| 20 |
(function "compare_move_peephole" |
| 21 |
(insn-chain |
| 22 |
(block 2 |
| 23 |
(edge-from entry (flags "FALLTHRU")) |
| 24 |
(cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) |
| 25 |
(cinsn 8 (set (reg:CC %cr0) |
| 26 |
(compare:CC (reg:DI %r3) |
| 27 |
(const_int 0)))) |
| 28 |
(cinsn 2 (set (reg:DI %r4) |
| 29 |
(reg:DI %r3))) |
| 30 |
;; Extra insn to avoid the above being deleted by DCE. |
| 31 |
(cinsn 18 (use (reg:DI %r4))) |
| 32 |
(cinsn 19 (use (reg:CC %cr0))) |
| 33 |
(edge-to exit (flags "FALLTHRU")) |
| 34 |
) ;; block 2 |
| 35 |
) ;; insn-chain |
| 36 |
) ;; function "main" |
| 37 |
} |
| 38 |
|
| 39 |
int __RTL (startwith ("peephole2")) move_compare_peephole () |
| 40 |
{ |
| 41 |
(function "move_compare_peephole" |
| 42 |
(insn-chain |
| 43 |
(block 2 |
| 44 |
(edge-from entry (flags "FALLTHRU")) |
| 45 |
(cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) |
| 46 |
(cinsn 2 (set (reg:DI %r4) |
| 47 |
(reg:DI %r3))) |
| 48 |
(cinsn 8 (set (reg:CC %cr0) |
| 49 |
(compare:CC (reg:DI %r3) |
| 50 |
(const_int 0)))) |
| 51 |
;; Extra insn to avoid the above being deleted by DCE. |
| 52 |
(cinsn 18 (use (reg:DI %r4))) |
| 53 |
(cinsn 19 (use (reg:CC %cr0))) |
| 54 |
(edge-to exit (flags "FALLTHRU")) |
| 55 |
) ;; block 2 |
| 56 |
) ;; insn-chain |
| 57 |
) ;; function "main" |
| 58 |
} |
| 59 |
|
| 60 |
/* { dg-final { scan-assembler-times {\mmr\.} 2 } } */ |