public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc port to StarCore
@ 2002-05-01  5:25 David Livshin
  2002-05-01  6:32 ` Alan Lehotsky
  0 siblings, 1 reply; 21+ messages in thread
From: David Livshin @ 2002-05-01  5:25 UTC (permalink / raw)
  To: gcc

Hi,

I am working on the port of the gcc version 3.0.1 to the StarCore
architecture ( DSP from Motorola/Agere ). The compiler works fine and
produces correct StarCore code that passes all the validations ( I have ).
However there are cases where it can do better job:

1. no constant propagation:

compiling with '-O3'

x = 10;
y = 100;
if ( x > y )
 return 0;
....

generates code to actually compare 'x' and 'y' disregarding the fact that
comparison always produces the same result.

This is not done in other versions of gcc, so what may be wrong in my
implementation that prevents compiler from performing necessary
optimizations? I don't think this problem relates to implementation of
integer comparison, as e.g.

x = 10;
y = 100;
z = y/x;

generates code to perform the division.

2. loop handling

my port generates weird an unoptimal code for loops. The body of the loop is
often has jumps to it ( as in the example below ) and consist of the
disjoint blocks that are spread over the generated code. The best looking
loop I seen gcc generates is for the code ( compiled with -O3 ):

for ( i = 0; i < 100; i++ )
sum += i;

 moveu.l #0,d3
 bra __L_L__8
__L_L__5:
 add d3,d0,d0
 add #1,d3
__L_L__8:
 moveu.l #99,d1
 sxt.l d3
 sxt.l d1
 cmpgt d1,d3
 bf __L_L__5

The jump  "bra __L_L__8" is not necessary ( may be this relates to the first
problem I described ) but even if it is necessary to determine if loop is
executed, what may prevent gcc from doing it before entering the body of the
loop ( like it is done in other implementations of gcc )?
In addition to disallowing many loop optimizations ( e.g. motion of the loop
invariant "moveu.l #99,d1" that sets the register "d1' to 99, out of loop ),
it seems that such a structure of a loop prevents the compiler to utilize
"decrement_and_branch_until_zero" and "doloop_begin/end" found in the md
file.

Thank you in advance,

David Livshin
dlivshin@internet-zahav.net
Tel:      +972 - 8 - 935 - 4597
Mobile: +972 - 67 - 290 - 998
Laskov 11/31
Rehovot, 76654
Israel


^ permalink raw reply	[flat|nested] 21+ messages in thread
* gcc port to StarCore
@ 2002-05-17  4:17 David Livshin
  2002-05-17 14:41 ` Richard Henderson
  0 siblings, 1 reply; 21+ messages in thread
From: David Livshin @ 2002-05-17  4:17 UTC (permalink / raw)
  To: gcc

Hi,

I am working on the port of the gcc version 3.0.1 to the StarCore
architecture ( DSP from Motorola/Agere ). Compiling ( without
optimizations ):

foo()
{
 int i;

 switch (i)
  case 1:
   break;
}

compiler generates the following pattern:
  ...

(insn 17 32 18 (set (cc0)
        (compare (reg:SI 3 d3 [43])
            (reg:SI 2 d2 [44]))) 63 {cmpsiEXPANDED} (nil)
    (nil))

(jump_insn 18 17 29 (set (pc)
        (if_then_else (eq (cc0)
                (const_int 0 [0x0]))
            (label_ref 21)
            (pc))) 52 {beqEXPANDED} (nil)
    (nil))
;; End of basic block 0, registers live:
 23 [r7] 32 [sp]

;; Start of basic block 1, registers live: 23 [r7] 32 [sp]
  ...

which stays valid till flow analysis ( last seen in ".postpreload" dump ).
In ".flow2" dump the above pattern is transformed into:


(insn 17 32 11 (set (cc0)
        (compare (reg:SI 3 d3 [43])
            (reg:SI 2 d2 [44]))) 63 {cmpsiEXPANDED} (nil)
    (nil))
;; End of basic block 0, registers live:
 23 [r7] 32 [sp]

( jump instruction being deleted ).

Is that correct? Documentation states that "GCC always generates a pair of
consecutive RTL insns, possibly separated by note insns, one to set the
condition code and one to test it, and _keeps the pair inviolate until the
end_."

While handling compare I am calling "next_cc0_usr" which in this case
returned 0; In addition to that I tried "find_reg_note (insn, REG_UNUSED,
cc0_rtx)" but it also failed. If the observed behavior of gcc is correct,
how should I treat this situation ( e.g. not generate code for compare )?

I checked my implementation of NOTICE_UPDATE_CC and it performed
CC_STATUS_INIT before handling compare ( as required ).

What could be wrong in my implementation?

Thank you in advance,

David Livshin
dlivshin@internet-zahav.net
Tel:      +972 - 8 - 935 - 4597
Mobile: +972 - 67 - 290 - 998
Laskov 11/31
Rehovot, 76654
Israel

http://www.dalsoft.esmartweb.com/


^ permalink raw reply	[flat|nested] 21+ messages in thread
* gcc port to StarCore
@ 2007-02-13  8:58 David Livshin
  2007-02-13 15:14 ` Ian Lance Taylor
  0 siblings, 1 reply; 21+ messages in thread
From: David Livshin @ 2007-02-13  8:58 UTC (permalink / raw)
  To: gcc


Hi,

I am converting my StarCore port of the gcc version 3.2 to the current version 4.1.1.
The following program ( part of the gcc's testsuite )

void bar(int *pc) {
  static const void *l[] = {&&lab0, &&end};

  foo(0);
  goto *l[*pc];
 lab0:
  foo(0);
  pc++;
  goto *l[*pc];
 end:
  return;
}


successfully compiled under 3.2 but under 4.1.1 I am getting the following error:


x.c: In function ‘bar’:
x.c:13: error: unrecognizable insn:
(jump_insn 26 25 27 2 (set (pc)
        (reg:SI 52)) -1 (nil)
    (nil))
x.c:13: internal compiler error: in extract_insn, at recog.c:2084


The .md file defines ( mandatory ) "indirect_jump" which allows ( a certain kind of ) register as parameter.
What is missing?

Thank you in advance,

David


-- 
David Livshin

http://www.dalsoft.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2007-02-13 17:33 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-01  5:25 gcc port to StarCore David Livshin
2002-05-01  6:32 ` Alan Lehotsky
2002-05-01 22:40   ` David Livshin
2002-05-01 23:22     ` Richard Henderson
2002-05-02  5:18       ` David Livshin
2002-05-02  5:46         ` Alan Lehotsky
2002-05-03  3:14           ` David Livshin
2002-05-03 11:38             ` Richard Henderson
2002-05-02  5:22     ` Alan Lehotsky
2002-05-02  7:38       ` David Livshin
2002-05-02  8:04         ` Alan Lehotsky
2002-05-03  3:01           ` David Livshin
2002-05-03 11:28             ` Alan Lehotsky
2002-05-17  4:17 David Livshin
2002-05-17 14:41 ` Richard Henderson
2002-05-19 23:30   ` David Livshin
2002-05-20  0:19     ` Richard Henderson
2007-02-13  8:58 David Livshin
2007-02-13 15:14 ` Ian Lance Taylor
2007-02-13 17:27   ` David Livshin
2007-02-13 17:33     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).