------- Additional Comments From schlie at comcast dot net  2004-11-17 07:21 
-------
Subject: Re:  3.4.3 ~6x+ performance regression vs
 3.3.1

> From: dmixm at marine dot febras dot ru <[EMAIL PROTECTED]>
> But foo_ll (shift loop with count 62!) and foo_l have remained on old -
> through shift of the left argument.

It would seem in general that if GCC in addition to transforming:

  ((size)x & (size)<pow-of-2-value>)) => (size)(x >> <log2-value>)

it also then transformed all RSHIFT expressions of the form:

  (size)(x >> <value>)
 =>
  (size-lsw)((subreg:(size-lsw) x:size lsw))  >> (<value>-(word-size*lsw)))

[where lsw is the lest significant pow-of-2 word which remains significant
 i.e lsw = 0 implies all words remain significant, lsw = 1 implies the
 precision of the result may be reduced by one word, etc.]

It would enable for a hypothetical 8-bit word-wide machine:

  (4-word-type)(X & 0x04000000)
=>
  (4-word-type)(X >> 26)
=>
  (1-word-type)((subreg:1-word-type X:4-word-type 3) >> 2)

Or for a 16-bit word wide machine: (or analogously for even wider machines)

  (2-word-type)(X & 0x04000000)
=>
  (2-word-type)(X >> 26)
=>
  (1-word-type)((subreg:1-word-type X:2-word-type 1) >> 10)

Which both enables the use of the resulting demoted precision value to be
expressed more optimally as an argument in subsequent expressions, and
to more optimally generate code on less-then-word-wide target machines.

Furthermore, the subreg representation of demoted expression values, could
also enable the potential further optimization of sign/zero extended values,
by allowing the detection of only sign or zero extended bits remaining
significant: 

  (4-word-type)((char)X & (long)0x04000000)
=>
  (4-word-type)((long<-char)X >> 26)
=>
  (1-word-type)((subreg:char ((long<-char)x):long 3) >> 2)
=>
  (1-word-type)((subreg:char (sign x):char 3) >> 2)
=>
  (1-word-type)(sign x)

Or something like that possibly.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18424

Reply via email to