| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-dp" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-O2" "-O3" "-Og" } } */ |
| 4 |
|
| 5 |
|
| 6 |
typedef struct dllist |
| 7 |
{ |
| 8 |
int i; |
| 9 |
struct dllist *ptr_to_next; |
| 10 |
struct dllist *ptr_to_previous; |
| 11 |
} dllist; |
| 12 |
|
| 13 |
int sglib_dllist_len(dllist *list) { |
| 14 |
int res; |
| 15 |
dllist *_dl_; |
| 16 |
int _r1_, _r2_; |
| 17 |
if (list== ((void *)0)) { |
| 18 |
res = 0; |
| 19 |
} else { |
| 20 |
dllist *_ce_; |
| 21 |
dllist *_ne_; |
| 22 |
_r1_ = 0; |
| 23 |
_ce_ = list; |
| 24 |
while (_ce_!= ((void *)0)) { |
| 25 |
_ne_ = _ce_->ptr_to_previous; |
| 26 |
_r1_++; |
| 27 |
_ce_ = _ne_; |
| 28 |
} |
| 29 |
_dl_ = list->ptr_to_next; |
| 30 |
_r2_ = 0; |
| 31 |
_ce_ = _dl_; |
| 32 |
while (_ce_!= (void *)0) { |
| 33 |
_ne_ = _ce_->ptr_to_next; |
| 34 |
_r2_++; |
| 35 |
_ce_ = _ne_; |
| 36 |
} |
| 37 |
res = _r1_ + _r2_; |
| 38 |
} |
| 39 |
return res; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
/* There was an unnecessary assignment to the return value until |
| 44 |
recently. Scan for that in the resulting output. */ |
| 45 |
/* { dg-final { scan-assembler-times "li\\ta0,0" 1 } } */ |
| 46 |
|