Index: tree-optimize.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v retrieving revision 1.1.4.73 diff -c -3 -p -r1.1.4.73 tree-optimize.c *** tree-optimize.c 17 Nov 2003 23:39:20 -0000 1.1.4.73 --- tree-optimize.c 25 Dec 2003 14:05:15 -0000 *************** Boston, MA 02111-1307, USA. */ *** 44,49 **** --- 44,54 ---- #include "tree-inline.h" #include "tree-mudflap.h" #include "ggc.h" + #include "tree-fold-const.h" + #include "tree-chrec.h" + #include "tree-scalar-evolution.h" + #include "tree-data-ref.h" + #include "tree-vectorizer.h" /* Rewrite a function tree to the SSA form and perform the SSA-based optimizations on it. */ *************** optimize_function_tree (tree fndecl, tre *** 169,176 **** --- 174,198 ---- #ifdef ENABLE_CHECKING verify_flow_info (); #endif + + if (flag_tree_vectorize) + { + struct loops *loops; + loops = loop_optimizer_init (NULL); + + if (loops != NULL) + { + vectorize_loops (fndecl, loops, TDI_vect); + loop_optimizer_finalize (loops, NULL); + } + } + + DBG_VECT2 (fprintf (stderr,"rewrite_out_of_ssa\n")); + /* Rewrite the function out of SSA form. */ rewrite_out_of_ssa (fndecl, TDI_optimized); + + DBG_VECT2 (fprintf (stderr,"done\n")); /* Flush out flow graph and SSA data. */ sbitmap_free (vars_to_rename); Index: tree-dump.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v retrieving revision 1.6.2.51 diff -c -3 -p -r1.6.2.51 tree-dump.c *** tree-dump.c 17 Nov 2003 23:39:19 -0000 1.6.2.51 --- tree-dump.c 25 Dec 2003 14:05:15 -0000 *************** static struct dump_file_info dump_files[ *** 674,682 **** --- 674,685 ---- {".ssa5", "tree-ssa5", 0, 0}, {".copyprop", "tree-copyprop", 0, 0}, {".dce2", "tree-dce2", 0, 0}, + {".vect", "tree-vect", 0, 0}, {".optimized", "tree-optimized", 0, 0}, {".mudflap", "tree-mudflap", 0, 0}, {".xml", "call-graph", 0, 0}, + {".scev", "scalar-evolutions", 0, 0}, + {".alldd", "all-data-deps", 0, 0}, {NULL, "tree-all", 0, 0}, }; Index: opts.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/opts.c,v retrieving revision 1.31.2.17 diff -c -3 -p -r1.31.2.17 opts.c *** opts.c 14 Nov 2003 16:50:01 -0000 1.31.2.17 --- opts.c 25 Dec 2003 14:05:15 -0000 *************** decode_options (unsigned int argc, const *** 539,544 **** --- 539,547 ---- flag_tree_must_alias = 1; flag_tree_pre = 1; flag_tree_ter = 1; + flag_scalar_evolutions = 0; + flag_all_data_deps = 0; + flag_tree_vectorize = 0; } if (optimize >= 2) *************** common_handle_option (size_t scode, cons *** 1415,1420 **** --- 1418,1435 ---- case OPT_ftree_dce: flag_tree_dce = value; + break; + + case OPT_fscalar_evolutions: + flag_scalar_evolutions = value; + break; + + case OPT_fall_data_deps: + flag_all_data_deps = value; + break; + + case OPT_ftree_vectorize: + flag_tree_vectorize = value; break; case OPT_ftree_combine_temps: Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.342.2.129 diff -c -3 -p -r1.342.2.129 tree.h *** tree.h 17 Nov 2003 23:39:20 -0000 1.342.2.129 --- tree.h 25 Dec 2003 14:05:16 -0000 *************** enum tree_dump_index *** 3558,3567 **** --- 3558,3570 ---- TDI_ssa_5, TDI_copyprop, TDI_dce_2, + TDI_vect, /* dump each function after vectorization. */ TDI_optimized, TDI_mudflap, /* dump each function after mudflap. */ TDI_xml, /* dump function call graph. */ + TDI_scev, /* dump scalar evolutions. */ + TDI_alldd, /* dump all data dependences. */ TDI_all, /* enable all the dumps above. */ TDI_end }; Index: timevar.def =================================================================== RCS file: /cvs/gcc/gcc/gcc/timevar.def,v retrieving revision 1.14.2.21 diff -c -3 -p -r1.14.2.21 timevar.def *** timevar.def 28 Oct 2003 14:56:21 -0000 1.14.2.21 --- timevar.def 25 Dec 2003 14:05:16 -0000 *************** DEFTIMEVAR (TV_TREE_CCP , "tree CC *** 76,81 **** --- 76,84 ---- DEFTIMEVAR (TV_TREE_PRE , "tree PRE") DEFTIMEVAR (TV_TREE_COPYPROP , "tree COPYPROP") DEFTIMEVAR (TV_TREE_DCE , "tree DCE") + DEFTIMEVAR (TV_SCALAR_EVOLUTIONS , "scalar evolutions") + DEFTIMEVAR (TV_ALL_DATA_DEPS , "all data dependences") + DEFTIMEVAR (TV_TREE_VECTORIZATION , "tree loop vectorization") DEFTIMEVAR (TV_TREE_SSA_TO_NORMAL , "tree SSA to normal") DEFTIMEVAR (TV_DOM_FRONTIERS , "dominance frontiers") DEFTIMEVAR (TV_OVERLOAD , "overload resolution") Index: common.opt =================================================================== RCS file: /cvs/gcc/gcc/gcc/common.opt,v retrieving revision 1.14.2.9 diff -c -3 -p -r1.14.2.9 common.opt *** common.opt 14 Nov 2003 16:50:00 -0000 1.14.2.9 --- common.opt 25 Dec 2003 14:05:16 -0000 *************** ftree-pre *** 742,747 **** --- 742,759 ---- Common Enable SSA-PRE optimization on trees + fscalar-evolutions + Common + Enable the analysis of scalar evolutions on trees + + fall-data-deps + Common + Analyze all the data dependences + + ftree-vectorize + Common + Enable loop vectorization on trees + funit-at-a-time Common Compile whole compilation unit at a time Index: toplev.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/toplev.c,v retrieving revision 1.654.2.75 diff -c -3 -p -r1.654.2.75 toplev.c *** toplev.c 14 Nov 2003 16:50:01 -0000 1.654.2.75 --- toplev.c 25 Dec 2003 14:05:17 -0000 *************** int flag_tree_copyprop; *** 999,1004 **** --- 999,1013 ---- /* Enable SSA-DCE on trees. */ int flag_tree_dce = 0; + /* Enable the analysis of the scalar evolutions on trees. */ + int flag_scalar_evolutions = 0; + + /* Enable the analysis of all data dependences. */ + int flag_all_data_deps = 0; + + /* Enable loop vectorization on trees */ + int flag_tree_vectorize = 0; + /* Enable promotion of virtual to real operands in must-alias situations. */ int flag_tree_must_alias = 0; *************** static const lang_independent_options f_ *** 1209,1214 **** --- 1218,1226 ---- { "tree-ccp", &flag_tree_ccp, 1 }, { "tree-copyprop", &flag_tree_copyprop, 1 }, { "tree-dce", &flag_tree_dce, 1 }, + { "scalar-evolutions", &flag_scalar_evolutions, 1 }, + { "all-data-deps", &flag_all_data_deps, 1 }, + { "tree-vectorize", &flag_tree_vectorize, 1}, { "tree-dominator-opts", &flag_tree_dom, 1 }, { "tree-combine-temps", &flag_tree_combine_temps, 1 }, { "tree-ter", &flag_tree_ter, 1 }, Index: flags.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/flags.h,v retrieving revision 1.86.2.38 diff -c -3 -p -r1.86.2.38 flags.h *** flags.h 14 Nov 2003 16:50:00 -0000 1.86.2.38 --- flags.h 25 Dec 2003 14:05:17 -0000 *************** extern int flag_tree_copyprop; *** 728,733 **** --- 728,742 ---- /* Enable SSA-DCE on trees. */ extern int flag_tree_dce; + /* Enable SSA-CHREC on trees. */ + extern int flag_scalar_evolutions; + + /* Enable the analysis of all the data dependences. */ + extern int flag_all_data_deps; + + /* Enable loop vectorization on trees */ + extern int flag_tree_vectorize; + /* Enable SSA->normal pass memory location coalescing. */ extern int flag_tree_combine_temps; Index: Makefile.in =================================================================== RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v retrieving revision 1.903.2.131 diff -c -3 -p -r1.903.2.131 Makefile.in *** Makefile.in 18 Nov 2003 08:49:28 -0000 1.903.2.131 --- Makefile.in 25 Dec 2003 14:05:18 -0000 *************** C_OBJS = c-parse.o c-lang.o stub-objc.o *** 888,893 **** --- 888,894 ---- # Language-independent object files. OBJS-common = \ + tree-vectorizer.o tree-chrec.o tree-scalar-evolution.o tree-data-ref.o tree-fold-const.o \ tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-simple.o \ tree-alias-type.o gimplify.o tree-nomudflap.o tree-pretty-print.o \ tree-alias-common.o tree-ssa-ccp.o tree-browser.o @ANDER@ tree-ssa-dce.o \ *************** tree-optimize.o : tree-optimize.c $(TREE *** 1600,1606 **** $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \ $(GGC_H) output.h diagnostic.h ssa.h errors.h flags.h tree-alias-common.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) toplev.h function.h \ ! langhooks.h flags.h cgraph.h tree-inline.h tree-mudflap.h $(GGC_H) c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \ $(C_TREE_H) $(C_COMMON_H) diagnostic.h $(TREE_SIMPLE_H) varray.h flags.h \ langhooks.h toplev.h rtl.h $(TREE_FLOW_H) langhooks-def.h \ --- 1601,1608 ---- $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \ $(GGC_H) output.h diagnostic.h ssa.h errors.h flags.h tree-alias-common.h \ $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) toplev.h function.h \ ! langhooks.h flags.h cgraph.h tree-inline.h tree-mudflap.h $(GGC_H) \ ! tree-fold-const.h tree-chrec.h tree-scalar-evolution.h tree-data-ref.h tree-vectorizer.h c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \ $(C_TREE_H) $(C_COMMON_H) diagnostic.h $(TREE_SIMPLE_H) varray.h flags.h \ langhooks.h toplev.h rtl.h $(TREE_FLOW_H) langhooks-def.h \ *************** gimple-low.o : gimple-low.c $(CONFIG_H) *** 1616,1621 **** --- 1618,1640 ---- tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \ $(TREE_H) errors.h tree-inline.h diagnostic.h $(HASHTAB_H) \ $(TM_H) coretypes.h + tree-fold-const.o: tree-fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) errors.h $(GGC_H) $(TREE_H) tree-fold-const.h + tree-chrec.o: tree-chrec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + errors.h $(GGC_H) $(TREE_H) tree-chrec.h tree-fold-const.h + tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) \ + $(BASIC_BLOCK_H) diagnostic.h $(TREE_FLOW_H) $(TREE_DUMP_H) \ + $(TIMEVAR_H) cfgloop.h tree-scalar-evolution.h tree-chrec.h \ + tree-data-ref.h tree-fold-const.h + tree-data-ref.o: tree-data-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \ + $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h \ + tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h + tree-vectorizer.o: tree-vectorizer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + errors.h $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) diagnostic.h \ + $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) cfgloop.h tree-chrec.h \ + tree-vectorizer.h tree-data-ref.h tree-scalar-evolution.h tree-fold-const.h simple-break-elim.o : simple-break-elim.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ $(C_TREE_H) $(C_COMMON_H) diagnostic.h tree-dchain.h $(TM_H) coretypes.h simple-goto-elim.o : simple-goto-elim.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ Index: defaults.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/defaults.h,v retrieving revision 1.80.2.23 diff -c -3 -p -r1.80.2.23 defaults.h *** defaults.h 13 Nov 2003 02:37:51 -0000 1.80.2.23 --- defaults.h 25 Dec 2003 14:05:19 -0000 *************** You Lose! You must define PREFERRED_DEB *** 596,601 **** --- 596,605 ---- #define VECTOR_MODE_SUPPORTED_P(MODE) 0 #endif + #ifndef UNITS_PER_SIMD_WORD + #define UNITS_PER_SIMD_WORD 0 + #endif + /* Determine whether __cxa_atexit, rather than atexit, is used to register C++ destructors for local statics and global objects. */ #ifndef DEFAULT_USE_CXA_ATEXIT Index: target-def.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/target-def.h,v retrieving revision 1.29.2.23 diff -c -3 -p -r1.29.2.23 target-def.h *** target-def.h 13 Nov 2003 02:38:00 -0000 1.29.2.23 --- target-def.h 25 Dec 2003 14:05:19 -0000 *************** Foundation, 59 Temple Place - Suite 330, *** 268,273 **** --- 268,276 ---- #define TARGET_INIT_BUILTINS hook_void_void #define TARGET_EXPAND_BUILTIN default_expand_builtin + /* In tree-vectorizer.c. */ + #define TARGET_VECTYPE_FOR_SCALAR_TYPE 0 + /* In varasm.c. */ #ifndef TARGET_SECTION_TYPE_FLAGS #define TARGET_SECTION_TYPE_FLAGS default_section_type_flags *************** Foundation, 59 Temple Place - Suite 330, *** 362,367 **** --- 365,371 ---- TARGET_MS_BITFIELD_LAYOUT_P, \ TARGET_INIT_BUILTINS, \ TARGET_EXPAND_BUILTIN, \ + TARGET_VECTYPE_FOR_SCALAR_TYPE, \ TARGET_INIT_LIBFUNCS, \ TARGET_SECTION_TYPE_FLAGS, \ TARGET_CANNOT_MODIFY_JUMPS_P, \ Index: target.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/target.h,v retrieving revision 1.32.2.24 diff -c -3 -p -r1.32.2.24 target.h *************** struct gcc_target *** 302,307 **** --- 302,312 ---- /* Expand a target-specific builtin. */ rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget, enum machine_mode mode, int ignore); + + /* Given a scalar type (e.g., HI_type_node) return the + corresponding vector type (e.g., V8HI_type_node or V16HI_type_node etc.) + if supported. Return NULL otherwise. */ + tree (* vectype_for_scalar_type) (tree scalar_tree_type); /* Make any adjustments to libfunc names needed for this target. */ void (* init_libfuncs) (void); Index: tree-flow-inline.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v retrieving revision 1.1.2.58 diff -c -3 -p -r1.1.2.58 tree-flow-inline.h *** tree-flow-inline.h 16 Nov 2003 08:24:02 -0000 1.1.2.58 --- tree-flow-inline.h 25 Dec 2003 14:05:19 -0000 *************** addresses_taken (tree stmt) *** 230,235 **** --- 230,241 ---- return ann ? ann->addresses_taken : NULL; } + static inline void * + stmt_info (stmt_ann_t ann) + { + return ann ? ann->aux : NULL; + } + static dataflow_t get_immediate_uses (tree stmt) { Index: tree-flow.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v retrieving revision 1.1.4.153 diff -c -3 -p -r1.1.4.153 tree-flow.h *** tree-flow.h 17 Nov 2003 23:18:13 -0000 1.1.4.153 --- tree-flow.h 25 Dec 2003 14:05:19 -0000 *************** struct stmt_ann_d GTY(()) *** 253,258 **** --- 253,261 ---- /* Array of variables that have had their address taken in the statement. */ varray_type addresses_taken; + + /* Place holder for optimization passes to record information. */ + char *aux; /* FIXME */ }; *************** static inline varray_type vuse_ops (stmt *** 291,296 **** --- 294,300 ---- static inline varray_type use_ops (stmt_ann_t); static inline varray_type def_ops (stmt_ann_t); static inline varray_type addresses_taken (tree); + static inline void *stmt_info (stmt_ann_t); static inline int num_immediate_uses (dataflow_t); static inline tree immediate_use (dataflow_t, int); static inline dataflow_t get_immediate_uses (tree); Index: config/rs6000/rs6000.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v retrieving revision 1.332.2.33 diff -c -3 -p -r1.332.2.33 rs6000.c *** config/rs6000/rs6000.c 13 Nov 2003 02:38:36 -0000 1.332.2.33 --- config/rs6000/rs6000.c 25 Dec 2003 14:05:22 -0000 *************** static rtx rs6000_expand_unop_builtin (e *** 305,310 **** --- 305,311 ---- static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx); static rtx rs6000_expand_ternop_builtin (enum insn_code, tree, rtx); static rtx rs6000_expand_builtin (tree, rtx, rtx, enum machine_mode, int); + static tree rs6000_vectype_for_scalar_type (tree); static void altivec_init_builtins (void); static void rs6000_common_init_builtins (void); static void rs6000_init_libfuncs (void); *************** static const char alt_reg_names[][8] = *** 507,512 **** --- 508,516 ---- #undef TARGET_EXPAND_BUILTIN #define TARGET_EXPAND_BUILTIN rs6000_expand_builtin + #undef TARGET_VECTYPE_FOR_SCALAR_TYPE + #define TARGET_VECTYPE_FOR_SCALAR_TYPE rs6000_vectype_for_scalar_type + #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS rs6000_init_libfuncs *************** rs6000_common_init_builtins (void) *** 7183,7188 **** --- 7187,7271 ---- def_builtin (d->mask, d->name, type, d->code); } + } + + /* Given a type of a scalar tree operation, return the type of the + corresponding vector operation. + */ + tree + rs6000_vectype_for_scalar_type (tree tree_type) + { + bool is_unsigned = TREE_UNSIGNED (tree_type); + + if (TARGET_SPE) + { + if (is_unsigned) + { + switch (TYPE_MODE (tree_type)) + { + case SImode: + return unsigned_V2SI_type_node; + case HImode: + return unsigned_V4HI_type_node; + case DImode: + return unsigned_V1DI_type_node; + default: + return NULL; + } + } + else + { + switch (TYPE_MODE (tree_type)) + { + case SFmode: + return V2SF_type_node; + case SImode: + return V2SI_type_node; + case HImode: + return V4HI_type_node; + case DImode: + return V1DI_type_node; + default: + return NULL; + } + } + } + + if (TARGET_ALTIVEC) + { + if (is_unsigned) + { + switch (TYPE_MODE (tree_type)) + { + case SImode: + return unsigned_V4SI_type_node; + case HImode: + return unsigned_V8HI_type_node; + case QImode: + return unsigned_V16QI_type_node; + default: + return NULL; + } + } + else + { + switch (TYPE_MODE (tree_type)) + { + case SFmode: + return V4SF_type_node; + case SImode: + return V4SI_type_node; + case HImode: + return V8HI_type_node; + case QImode: + return V16QI_type_node; + default: + return NULL; + } + } + } + + return NULL; } static void Index: config/rs6000/rs6000.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v retrieving revision 1.210.2.29 diff -c -3 -p -r1.210.2.29 rs6000.h *** config/rs6000/rs6000.h 13 Nov 2003 02:38:39 -0000 1.210.2.29 --- config/rs6000/rs6000.h 25 Dec 2003 14:05:23 -0000 *************** extern enum rs6000_nop_insertion rs6000_ *** 1026,1031 **** --- 1026,1034 ---- ((TARGET_SPE && SPE_VECTOR_MODE (MODE)) \ || (TARGET_ALTIVEC && ALTIVEC_VECTOR_MODE (MODE))) + #define UNITS_PER_SIMD_WORD \ + (TARGET_ALTIVEC ? 16 : (TARGET_SPE ? 8 : 0) ) + /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. For POWER and PowerPC, the GPRs can hold any mode, but values bigger than one register cannot go past R31. The float