public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: question about ashlqi3 pattern
@ 2004-11-26  0:05 Paul Schlie
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Schlie @ 2004-11-26  0:05 UTC (permalink / raw)
  To: gcc

> Balaji S wrote:
>
> When I rebuilt GCC and tried with the following test case,
> *does not* giving me an *rtl with byte* (QI) shift operation.
> ..
> char a, b ;
> void fn1 () { a = b << 1 ; }
>
> Pls. help me, Why am i not getting a byte QI left shift?

Likely because GCC tends to initially literally promote all operands as
specified by C evaluation rules without consideration of the operations
true target precision requirements prior to attempting to determine if
the applied promotions were actually necessary based on modular arithmetic;
resulting in circumstances where the prematurely applied promotion obscure
their own ability to be subsequently reliably identified as being
unnecessary.

Which tends to have negligible effect on machines who's word-size is int or
wider, as by default, operands are effectively promoted to the machine's
word size (being int or wider) as a consequence of being loaded into the
register file by default; but for smaller machines, or those which may
benefit from inhibiting the promotion of operands to being no wider than
necessary, GCC's present promotion strategy tends to be less than optimal.
As for example, your code's specified operation is promoted to int precision
as literally specified by C, although not logically required to be, as the
un-promoted operation yields equivalent results as a consequence of the of
the operations specified target precision is only a char wide regardless of
it being signed or unsigned.

Therefore you may need to try to specify templates in your .md to identify
opportunities to nullify otherwise needlessly promoted operations/operands
occasionally preserved by GCC's front/middle ends if you can want to take
advantage of alternative less aggressively promoted equivalent evaluation
forms.


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

* Re: question about ashlqi3 pattern
@ 2004-11-25 14:20 Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2004-11-25 14:20 UTC (permalink / raw)
  To: sivanbalaji; +Cc: gcc

> When I rebuilt GCC and tried with the following test case, *does not* 
> giving me an *rtl with byte* (QI) shift operation.
>
> Note: I do not have PROMOTE_MODE macro. It is undefined.
>
>char a, b ;
>void fn1 () { a = b << 1 ; }
>

Try with "unsigned char a, b;"

Uros.

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

* question about ashlqi3 pattern
@ 2004-11-25 12:44 Balaji S
  0 siblings, 0 replies; 3+ messages in thread
From: Balaji S @ 2004-11-25 12:44 UTC (permalink / raw)
  To: gcc

Hi,
I am porting GCC to a new target. I took stormy16 as a base and converting it to the new target.

Since my new target is having byte instructions, i introduced a byte left shift instruction in m/c desc. with the standard pattern name "ashlqi3" as follows.

(define_insn "ashlqi3"
  [(set (match_operand:QI 0 "register_operand" "=r")
	(ashift:QI (match_operand:QI 1 "register_operand" "0")
		   (match_operand:QI 2 "immediate_operand"  "i")))]
  ""
  "sll	%0, %2"
  [(set_attr "length" "2")
   (set_attr "cc" "clobber")])

When I rebuilt GCC and tried with the following test case, *does not* giving me an *rtl with byte* (QI) shift operation.

Note: I do not have PROMOTE_MODE macro. It is undefined.

char a, b ;
void fn1 () { a = b << 1 ; }

rtl output by -dr:

(insn 8 6 9 0x0 (set (reg:QI 42)
        (mem/f:QI (symbol_ref:HI ("b")) [0 b+0 S1 A8])) -1 (nil)
    (nil))

(insn 9 8 10 0x0 (set (reg:HI 41)
        (sign_extend:HI (reg:QI 42))) -1 (nil)
    (nil))

(insn 10 9 11 0x0 (set (reg:HI 43)
        (ashift:HI (reg:HI 41)
            (const_int 1 [0x1]))) -1 (nil)
    (nil))

(insn 11 10 13 0x0 (set (mem/f:QI (symbol_ref:HI ("a")) [0 a+0 S1 A8])
        (subreg:QI (reg:HI 43) 0)) -1 (nil)
    (nil))

I have tried on avr also but same result.

Pls. help me, Why am i not getting a byte QI left shift?

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

end of thread, other threads:[~2004-11-25 23:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-26  0:05 question about ashlqi3 pattern Paul Schlie
  -- strict thread matches above, loose matches on Subject: below --
2004-11-25 14:20 Uros Bizjak
2004-11-25 12:44 Balaji S

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).