This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch for h8300 port


Hi,

> A very plausable explanation.  It would be still be
> interesting to know how removing the memory alternative
> affects optimized code, however.

I just removed the memory alternative to see what happens.  Looking at
the small example below, gcc was able to handle "post_inc" and
"constant index" separately from sign extention.  This is as complex
as one can get among different addressing modes on the H8.

/* h8300-hms-gcc -mh -Wall -O2 -fomit-frame-pointer  */

volatile int cond;

long
postinc (short *p)
{
  long sum = 0;

  while (cond)
    sum += *p++;

  while (cond)
    {
      p += sum;
      sum += p[5];
    }

  return sum;
}

The above code turned into:

_postinc:
	sub.l	er3,er3
	bra	.L15
.L7:
	mov.w	@er0+,r2
	exts.l	er2
	add.l	er2,er3
.L15:
	mov.w	@_cond,r2
	bne	.L7
	bra	.L16
.L11:
	mov.l	er3,er2
	add.l	er2,er2
	add.l	er2,er0
	mov.w	@(10,er0),r2
	exts.l	er2
	add.l	er2,er3
.L16:
	mov.w	@_cond,r2
	bne	.L11
	mov.l	er3,er0
	rts

Just to clear up where we are, I attached the patch I have.  I've
incorporated "@ removal" and "register_operand".

Kazu Hirata

===File ~/gnu/gcc/h8300ext.patch============================
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/h8300/h8300.md,v
retrieving revision 1.20
diff -c -3 -r1.20 h8300.md
*** h8300.md	2000/09/14 18:09:16	1.20
--- h8300.md	2000/10/07 00:58:34
***************
*** 1667,1680 ****
     (set_attr "cc" "clobber,clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:SI 0 "register_operand" "=r,r")
! 	(zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "@
!   extu.l	%S0
!   mov.w	%T1,%T0\;extu.l	%S0"
!   [(set_attr "length" "2,4")
!    (set_attr "cc" "set_znv,set_znv")])
  
  (define_expand "extendqihi2"
    [(set (match_operand:HI 0 "register_operand" "")
--- 1667,1678 ----
     (set_attr "cc" "clobber,clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:SI 0 "register_operand" "=r")
! 	(zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "extu.l	%S0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "set_znv")])
  
  (define_expand "extendqihi2"
    [(set (match_operand:HI 0 "register_operand" "")
***************
*** 1693,1706 ****
     (set_attr "cc" "clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:HI 0 "register_operand" "=r,r")
! 	(sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "@
!   exts.w	%T0
!   mov.b	%R1,%s0\;exts.w	%T0"
!   [(set_attr "length" "2,4")
!    (set_attr "cc" "set_znv,set_znv")])
  
  ;; The compiler can synthesize a 300H variant of this which is
  ;; just as efficient as one that we'd create
--- 1691,1702 ----
     (set_attr "cc" "clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "exts.w	%T0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "set_znv")])
  
  ;; The compiler can synthesize a 300H variant of this which is
  ;; just as efficient as one that we'd create
***************
*** 1749,1762 ****
     (set_attr "cc" "clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:SI 0 "register_operand" "=r,r")
! 	(sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "@
!   exts.l	%S0
!   mov.w	%T1,%T0\;exts.l	%S0"
!   [(set_attr "length" "2,4")
!    (set_attr "cc" "set_znv,set_znv")])
  
  ;; ----------------------------------------------------------------------
  ;; SHIFTS
--- 1745,1756 ----
     (set_attr "cc" "clobber,clobber")])
  
  (define_insn ""
!   [(set (match_operand:SI 0 "register_operand" "=r")
! 	(sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
    "TARGET_H8300H || TARGET_H8300S"
!   "exts.l	%S0"
!   [(set_attr "length" "2")
!    (set_attr "cc" "set_znv")])
  
  ;; ----------------------------------------------------------------------
  ;; SHIFTS
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]