Having trouble in porting gcc 2.95
Takayoshi Kouchi
t-kouchi@sannet.ne.jp
Wed Dec 15 03:04:00 GMT 1999
Hi, I'm porting gcc 2.95 to a new architecture
and having a trouble.
Please help me!
The problem is as follows...
Here is the source (from gzip-1.2.4)
==========================================
extern int optind;
static int first_nonopt;
static int last_nonopt;
static void
exchange (argv)
char **argv;
{
char *temp, **first, **last;
first = &argv[first_nonopt];
last = &argv[optind-1];
while (first < last) {
temp = *first; *first = *last; *last = temp; first++; last--;
}
first = &argv[first_nonopt];
first_nonopt += (optind - last_nonopt);
last = &argv[first_nonopt - 1];
while (first < last) {
temp = *first; *first = *last; *last = temp; first++; last--;
}
first = &argv[first_nonopt];
last_nonopt = optind;
last = &argv[last_nonopt-1];
while (first < last) {
temp = *first; *first = *last; *last = temp; first++; last--;
}
}
==========================================
The architecture doesn't have flag register, but have
conditional branch instructions, which compares a register
and 0.
So we implemented in the md file that
compare and test instructions will only make information of
condition and compared registers and conditional branch
instructions will use the information, as mips one does.
If we compile the source with -O, all the 'while' loops are
entirely eliminated. As I investigated when they were
eliminated, I found that it disappeared in the 1st cse stage.
After the 1st jump optimization, it looked like that result of
the comparison would be stored in pseudo register 170.
> (insn 131 18 132 (set (reg:DI 170)
> (compare:DI (reg/v:DI 135)
> (reg/v:DI 136))) -1 (nil)
> (nil))
>
> (jump_insn 132 131 20 (set (pc)
> (if_then_else (geu:DI (reg:DI 170)
> (const_int 0 [0x0]))
> (label_ref 42)
> (pc))) 53 {internal_branch_di} (nil)
> (nil))
>
> (note 20 132 26 "" NOTE_INSN_LOOP_BEG)
>
> (code_label 26 20 28 5 "" [num uses: 1])
>
> ... and loop body follows (snip)
>
> (note 35 33 135 "" NOTE_INSN_LOOP_CONT)
>
> (note 135 35 22 "" NOTE_INSN_LOOP_VTOP)
>
> (insn 22 135 23 (set (reg/s:DI 144)
> (compare:DI (reg/v:DI 135)
> (reg/v:DI 136))) -1 (nil)
> (nil))
>
> (jump_insn 23 22 41 (set (pc)
> (if_then_else (ltu:DI (reg/s:DI 144)
> (const_int 0 [0x0]))
> (label_ref 26)
> (pc))) -1 (nil)
> (nil))
>
> (note 41 23 42 "" NOTE_INSN_LOOP_END)
After the 1st cse, the loop were entirely eliminated as follows.
> (note 20 18 28 "" NOTE_INSN_LOOP_BEG)
>
> (note 28 20 35 "" NOTE_INSN_DELETED)
>
> (note 35 28 135 "" NOTE_INSN_LOOP_CONT)
>
> (note 135 35 23 "" NOTE_INSN_LOOP_VTOP)
>
> (note 23 135 41 "" NOTE_INSN_DELETED)
>
> (note 41 23 44 "" NOTE_INSN_LOOP_END)
I have no idea why such a situation appears.
Probably, I have missed someting in the machine description
or target macros...
Any hints are welcome.
---
Takayoshi Kouchi
More information about the Gcc
mailing list