Question about mem_set_list in propagate_block_info
Daniel Jacobowitz
drow@mvista.com
Wed Jun 4 14:59:00 GMT 2003
On Wed, Jun 04, 2003 at 08:44:02AM -0500, Fred Fish wrote:
> > I still bet his source is wrong.
>
> Here's the source:
>
> typedef int matrix_t __attribute__((__mode__(V16SI)));
>
> #define MATRIX_ELEMENT(m,r,c) (*(((int *)&(m))+(r)*sizeof(int)+(c)))
>
> int foo ()
> {
> matrix_t in1 = {7,1,4,1,5,9,2,6,5,3,5,8,9,7,9,2};
> int m00 = MATRIX_ELEMENT (in1, 0, 0);
> return (m00);
> }
That looks to me like an aliasing violation: GCC considers int
__attribute__ ((__mode__(V16SI))) and int to be different types.
Accessing a matrix_t via an int * is illegal.
It's not really what you want to do either. That's probably more
likely to commit the variable to memory than is strictly necessary.
Something like
union matrix_t { int m __attribute__((__mode__(V16SI))); int x[16]; };
>
> And here is the *.cse2 rtl before the life analysis pass that deletes
> most of the code:
>
> ;; Processing block from 2 to 0, 7 sets.
> (note 2 0 3 NOTE_INSN_DELETED)
>
> (note 3 2 28 NOTE_INSN_FUNCTION_BEG)
>
> ;; Start of basic block 0, registers live: (nil)
> (note 28 3 8 0 [bb 0] NOTE_INSN_BASIC_BLOCK)
>
> (insn 8 28 9 0 0x4029aa40 (set (reg/f:SI 209)
> (high:SI (symbol_ref/u:SI ("*$LC0") [flags 0x2]))) 188 {movsi_internal} (nil)
> (nil))
>
> (insn 9 8 10 0 0x4029aa40 (set (reg/f:SI 208)
> (lo_sum:SI (reg/f:SI 209)
> (symbol_ref/u:SI ("*$LC0") [flags 0x2]))) 180 {lowsi} (nil)
> (expr_list:REG_EQUAL (symbol_ref/u:SI ("*$LC0") [flags 0x2])
> (nil)))
>
> (insn 10 9 11 0 0x4029aa40 (set (reg:V16SI 210)
> (mem/u/f:V16SI (reg/f:SI 208) [3 S64 A512])) 355 {*movv16si_internal} (nil)
> (expr_list:REG_EQUAL (const_vector:V16SI [
> (const_int 7 [0x7])
> (const_int 1 [0x1])
> (const_int 4 [0x4])
> (const_int 1 [0x1])
> (const_int 5 [0x5])
> (const_int 9 [0x9])
> (const_int 2 [0x2])
> (const_int 6 [0x6])
> (const_int 5 [0x5])
> (const_int 3 [0x3])
> (const_int 5 [0x5])
> (const_int 8 [0x8])
> (const_int 9 [0x9])
> (const_int 7 [0x7])
> (const_int 9 [0x9])
> (const_int 2 [0x2])
> ])
> (nil)))
>
> (insn 11 10 13 0 0x4029aa40 (set (mem/f:V16SI (reg/f:SI 1 at) [3 S64 A512])
> (reg:V16SI 210)) 355 {*movv16si_internal} (nil)
> (nil))
>
> (insn 13 11 21 0 0x4029aa40 (set (reg/v:SI 211 [ m00 ])
> (mem:SI (reg/f:SI 1 at) [4 S4 A32])) 188 {movsi_internal} (nil)
> (nil))
>
> (note 21 13 24 0 NOTE_INSN_FUNCTION_END)
>
> (insn 24 21 27 0 (nil) (set (reg/i:SI 2 v0 [ <result> ])
> (reg/v:SI 211 [ m00 ])) 188 {movsi_internal} (nil)
> (nil))
>
> (insn 27 24 0 0 (nil) (use (reg/i:SI 2 v0 [ <result> ])) -1 (nil)
> (nil))
> ;; End of basic block 0, registers live:
> (nil)
>
>
> And the RTL from *.life:
>
> ;; Start of basic block 0, registers live: 0 [$0] 1 [$1] 28 [$28] 29 [$sp] 30 [$fp] 31 [$31]
> (note 28 3 13 0 [bb 0] NOTE_INSN_BASIC_BLOCK)
>
> (insn 13 28 21 0 0x4029aa40 (set (reg/v:SI 211 [ m00 ])
> (mem:SI (reg/f:SI 1 at) [4 S4 A32])) 188 {movsi_internal} (nil)
> (nil))
>
> (note 21 13 24 0 NOTE_INSN_FUNCTION_END)
>
> (insn 24 21 27 0 (nil) (set (reg/i:SI 2 v0 [ <result> ])
> (reg/v:SI 211 [ m00 ])) 188 {movsi_internal} (insn_list 13 (nil))
> (expr_list:REG_DEAD (reg/v:SI 211 [ m00 ])
> (nil)))
>
> (insn 27 24 0 0 (nil) (use (reg/i:SI 2 v0 [ <result> ])) -1 (insn_list 24 (nil))
> (nil))
> ;; End of basic block 0, registers live:
> 0 [$0] 1 [$1] 2 [$2] 28 [$28] 29 [$sp] 30 [$fp] 31 [$31]
>
> -Fred
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
More information about the Gcc
mailing list