Just like PR 28367: #define vector __attribute__((vector_size(16))) float f(vector float t) { return *(float*)&t; } We get a full vector store which we can get around with a stvewx which just stores that one element and we can get that via a vec_extract pattern. On x86_64 has the same issue, maybe even worse as there is no need to go through memory there. X86_64 produces: f: .LFB2: movaps %xmm0, -24(%rsp) movss -24(%rsp), %xmm0 ret When really it should produce just a ret.
I have a patch to fix this and other bugs that show up because of the more uses of vec_set/vec_extract which I will submit when I get back in the US.
Testing a fix for this one, though it only does the simple *(int*)&vector_int_var case.
Note I Noticed with vector int on x86, it incorrectly uses SF mode because vec_extract is done wrongly.
Subject: Bug 28436 Author: pinskia Date: Tue Dec 12 22:33:06 2006 New Revision: 119801 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119801 Log: 2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/28436 * tree.h (DECL_COMPLEX_GIMPLE_REG_P): Rename to ... (DECL_GIMPLE_REG_P): This. * fold-const.c (fold_indirect_ref_1): Fold *(foo *)&vectorfoo into using BIT_FIELD_REF. * omp-low.c (omp_copy_decl_2): Use the renamed DECL_GIMPLE_REG_P. * tree-gimple.c (is_gimple_reg): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. * expr.c (get_inner_reference): Set the mode for BIT_FIELD_REF with vector types. * tree-flow-inline.h (var_can_have_subvars): Use the renamed DECL_GIMPLE_REG_P. * gimplify.c (internal_get_tmp_var): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. (gimplify_bind_expr): Likewise. (gimplify_function_tree): Likewise. * expmed.c: Include target.h. (extract_bit_field): For vector mode, try find a better mode first. If that fails use gen_lowpart (for vectors only). * tree-dfa.c (make_rename_temp): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. * tree-ssa-pre.c (create_expressions_by_pieces): Likewise. (insert_into_preds_of_block): Likewise. (insert_fake_stores): Create gimple register store_tmps for vector types. * tree-sra.c (sra_elt): New field, is_vector_lhs. (sra_walk_expr <case BIT_FIELD_REF>): For vector types that are the left hand side, set the element's is_vector_lhs to true. (instantiate_element): For vector types which were on the left hand size, set DECL_GIMPLE_REG_P to false. * tree-nested.c (create_tmp_var_for): Use the renamed DECL_GIMPLE_REG_P. * tree-inline.c (declare_return_variable): Use the renamed DECL_GIMPLE_REG_P and check for VECTOR_TYPE. (copy_decl_to_var): Use the renamed DECL_GIMPLE_REG_P. (copy_result_decl_to_var): Likewise. * tree-vect-transform.c (vect_get_new_vect_var): For vector types, create a gimple register variable. (vect_permute_store_chain): Set DECL_GIMPLE_REG_P to true for the vect_inter_* temp variables. * Makefile.in (expmed.o): Update dependencies. 2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/28436 * gcc.c-torture/compile/vector-1.c: New test. * gcc.c-torture/compile/vector-2.c: New test. * gcc.c-torture/compile/vector-3.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/vector-1.c trunk/gcc/testsuite/gcc.c-torture/compile/vector-2.c trunk/gcc/testsuite/gcc.c-torture/compile/vector-3.c Modified: trunk/gcc/ChangeLog trunk/gcc/Makefile.in trunk/gcc/expmed.c trunk/gcc/expr.c trunk/gcc/fold-const.c trunk/gcc/gimplify.c trunk/gcc/omp-low.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-dfa.c trunk/gcc/tree-flow-inline.h trunk/gcc/tree-gimple.c trunk/gcc/tree-inline.c trunk/gcc/tree-nested.c trunk/gcc/tree-sra.c trunk/gcc/tree-ssa-pre.c trunk/gcc/tree-vect-transform.c trunk/gcc/tree.h
Fixed mostly, I will file a new bug for the other issues, in that a nonzero index and a non constant index.