Question about UNSPEC rtx and a new instruction

2009-01-06 Thread JCX
Hello, I am working on a gcc porting for a new instruction. This
instruction needs to move data from memory to two registers. So I use
the SET rtx, and the dest of SET is an UNSPEC rtx with two registers.
By using such a rtl pattern, gcc performs very differently. It makes
mistakes for register replacement and instruction reordering.
For example, when gcc optimizes in pass_cse, it performs register
substitution of registers in UNSPEC rtx without checking the validity
of the resulting insn.
So I wonder about the UNSPEC rtx.

What's the usage of UNSPEC rtx?

And do you have a better rtl pattern for this new instruction?

Thanks,
Jacy


Question about type conversion when GCC compile the file?

2009-02-18 Thread JCX
Hello,
 After I compile the following file for testing, I check the dump
file called "129t.final_cleanup". I doubt about why the type "short
int" changes into "short unsigned int" during the array operations,
and at last changes back to "short int" when it stores the result into
memory.

 The source file is :

 short int a[20], b[20], c[20];
 int main(){
 int i;
 for(i=0; i<20; i++)
a[i]=b[i]+c[i];
 return 0;
 }

 The dump file is:

;; Function main (main)

main ()
{
  unsigned int ivtmp.31;

:
  ivtmp.31 = 0;

:
  MEM[base: &a + ivtmp.31] = (short int) ((short unsigned int)
MEM[base: &c + ivtmp.31] + (short unsigned int) MEM[base: &b +
ivtmp.31]);
  ivtmp.31 = ivtmp.31 + 2;
  if (ivtmp.31 != 40)
goto ;
  else
goto ;

:
  return 0;

}

 I don't know why GCC do such a type conversion.  Can anyone tell me?
This makes me more difficult to do the optimization in GCC.

 Thanks very much!
 Caixia


Question about RTL expander?

2009-02-19 Thread JCX
Hello,
After I vectorize the following file by GCC for testing, it gets the
right "129t.final_cleanup" file. However, it expands to the wrong
vector type when stores the "short int" into memory. I have checked
many times, but I still don't know why.  Can anyone help me?

The source file is:
short int b[20], c[20];

int main(){
int i;

for(i=0; i<20; i++)
{
   b[i]=6;
   c[i]=9;
}
return 0;
}

The 129t.final_cleanup file is:
;; Function main (main)

main ()
{
  unsigned int ivtmp.44;

:
  ivtmp.44 = 0;

:
  MEM[base: &b + ivtmp.44] = { 6, 6, 6, 6 };//It rightly expands
here! And it rightly vectorizes here!
  MEM[base: &c + ivtmp.44] = { 9, 9, 9, 9 };
  ivtmp.44 = ivtmp.44 + 8;
  if (ivtmp.44 != 40)
goto ;
  else
goto ;

:
  return 0;

}

The "131r.expand" file is:

(insn 52 51 53 4 hello21.c:10 (set (reg/f:SI 241)
(symbol_ref:SI ("b") )) -1 (nil))

(insn 53 52 54 4 hello21.c:10 (set (reg:SI 240)
(plus:SI (reg/f:SI 241)
(reg:SI 238 [ ivtmp.44 ]))) -1 (nil))

(insn 54 53 55 4 hello21.c:10 (set (reg:SI 242)
(high:SI (symbol_ref/u:SI ("*.LC0") [flags 0x2]))) -1 (nil))

(insn 55 54 56 4 hello21.c:10 (set (reg:V2SI 243)
// why it expands the scalar type to "V2SI" rather than "V4HI", which
is different from "129t.final_cleanup" file
(mem/u/c/i:V2SI (lo_sum:SI (reg:SI 242)
(symbol_ref/u:SI ("*.LC0") [flags 0x2])) [4 S8 A64])) -1 (nil))

(insn 56 55 57 4 hello21.c:10 (set (mem:V2SI (reg:SI 240) [4 S8 A64])
(reg:V2SI 243)) -1 (nil))

Why it expands to the wrong type?

Thanks very much!
Caixia