From: Thierry L. <thi...@in...> - 2010-03-10 09:38:56
|
Hi Andrea, Thanks for your remark. I'll make use of OPTIMIZATION_OPTIONS: it's a macro which is called in opts.c (whereas OVERRIDE_OPTIONS is called from toplev.c). Thierry Lafage. Andrea Carlo Ornstein a écrit : > Hi, > Sorry for the late replay. > > I have left only one remark (Gabriele and Erven already addressed all > the others). > > We should probably avoid the changes in gcc/opts.c > the right way of doing it is by defining OPTIMIZATION_OPTIONS in > cil32.h as we did for OVERRIDE_OPTIONS > You can look for an example on how to use them to gcc/config/cris/cris.[hc] > it defines both OPTIMIZATION_OPTIONS and OVERRIDE_OPTIONS > > I do not remember exactly the difference of the two, so I do not know > exactly where to put it, but the option does not exists for other > targets. > > Andrea > > > > > On Mon, Mar 8, 2010 at 5:39 PM, Thierry Lafage <thi...@in...> wrote: > >> Hi all, >> >> Here are several small patches for our gcc4cli BE branch: >> >> pr19340.c.patch is to avoid testing with pr19340.c because it has no sense >> in cil32 since it tests the scheduler. >> gcc4cli_line_info-t-cil32.patch fixes dependencies in t-cil32 and adds the >> file source-location.h which was introduced in my last patch concerning >> source location (this t-cil32 patch should have been part of the source >> location patch). >> cil-lower.c.patch modifies the pass gate in order to activate this pass only >> when -ftree_vectorize option is activated (which is the case in -O3) >> and simp-cond.patch is a simplification of the simp-cond pass which also >> makes it more complete (adds support for brtrue/brfalse and for floating >> point comparisons in conditional branches + add a command-line option which >> is activated in -O1 + fixes missing brtrue/brfalse as being conditional >> branch instructions). Note that this pass either does nothing, or change a >> branch condition instruction into another one (inverts the condition) and >> removes the following unconditional branch. This means that the stack is not >> changed at all, so I removed all the stuff that was recomputing the stack at >> every statement. Moreover, I didn't understand the test on the conditional >> branch operand type (integer or pointer) in order to change the conditional >> br instruction: I've removed it and tested on a real program, and it seems >> to be ok. More tests are on the way (check-gcc + cbenchmarks). >> >> Feel free to comment. I should commit in a few days if you're ok (or if you >> don't say anything). >> >> Regards, >> >> Thierry Lafage. >> >> Index: gcc/config/cil32/cil-lower.c >> =================================================================== >> --- gcc/config/cil32/cil-lower.c (revision 156016) >> +++ gcc/config/cil32/cil-lower.c (working copy) >> @@ -1,6 +1,6 @@ >> /* CIL IR lowering. >> >> - Copyright (C) 2009 Free Software Foundation, Inc. >> + Copyright (C) 2009-2010 Free Software Foundation, Inc. >> >> This file is part of GCC. >> >> @@ -23,11 +23,13 @@ >> Andrea C. Ornstein >> Erven Rohou >> Gabriele Svelto >> + Thierry Lafage >> >> Contact information at STMicroelectronics: >> Andrea C. Ornstein <and...@st...> >> Contact information at INRIA: >> Erven Rohou <erv...@in...> >> +Thierry Lafage <thi...@in...> >> */ >> >> #include <stdio.h> >> @@ -52,6 +54,8 @@ >> * Globals >> * >> ******************************************************************************/ >> >> +extern int flag_tree_vectorize; // TL // This avoids including options.h >> + >> enum simd_backend simd_type = UNDEF_SIMD; >> >> /****************************************************************************** >> @@ -591,8 +595,7 @@ >> static bool >> lower_cil_gate (void) >> { >> - /* FIXME: should lower only if vector types are handled in this funtion. >> */ >> - return true; >> + return flag_tree_vectorize != 0; >> } >> >> >> >> Index: gcc/config/cil32/t-cil32 >> =================================================================== >> --- gcc/config/cil32/t-cil32 (revision 156016) >> +++ gcc/config/cil32/t-cil32 (working copy) >> @@ -110,6 +110,7 @@ >> $(srcdir)/config/cil32/cil-stmt.h \ >> $(srcdir)/config/cil32/cil-types.h \ >> $(srcdir)/config/cil32/emit-cil.h \ >> + $(srcdir)/config/cil32/source-location.h \ >> $(CONFIG_H) $(FLAGS_H) $(GGC_H) \ >> $(SYSTEM_H) $(TIMEVAR_H) $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_PASS_H) >> \ >> coretypes.h errors.h pointer-set.h >> @@ -134,6 +135,7 @@ >> missing-protos.o : $(srcdir)/config/cil32/missing-protos.c \ >> $(srcdir)/config/cil32/cil-refs.h $(srcdir)/config/cil32/cil-stmt.h \ >> $(srcdir)/config/cil32/cil-stmt-inline.h >> $(srcdir)/config/cil32/cil-stack.h \ >> + $(srcdir)/config/cil32/source-location.h \ >> $(srcdir)/config/cil32/cil-types.h $(CONFIG_H) $(FLAGS_H) $(SYSTEM_H) \ >> $(TIMEVAR_H) $(TM_H) $(TREE_H) $(TREE_PASS_H) coretypes.h errors.h \ >> pointer-set.h >> >> Index: gcc/testsuite/gcc.dg/pr19340.c >> =================================================================== >> --- gcc/testsuite/gcc.dg/pr19340.c (revision 156016) >> +++ gcc/testsuite/gcc.dg/pr19340.c (working copy) >> @@ -1,6 +1,6 @@ >> /* { dg-do compile } */ >> /* { dg-options "-O1 -fschedule-insns2 -fsched2-use-traces" } */ >> -/* { dg-skip-if "No scheduling" { mmix-*-* cris-*-* crisv32-*-* fido-*-* >> m68k-*-* m32c-*-* avr-*-* } { "*" } { "" } } */ >> +/* { dg-skip-if "No scheduling" { mmix-*-* cris-*-* crisv32-*-* fido-*-* >> m68k-*-* m32c-*-* avr-*-* cil32-*-* } { "*" } { "" } } */ >> >> extern double f (double x); >> >> >> Index: gcc/opts.c >> =================================================================== >> --- gcc/opts.c (revision 156016) >> +++ gcc/opts.c (working copy) >> @@ -914,6 +914,7 @@ >> flag_tree_copy_prop = opt1; >> flag_tree_sink = opt1; >> flag_tree_ch = opt1; >> + flag_cil32_simp_cond = opt1; >> >> /* -O2 optimizations. */ >> opt2 = (optimize >= 2); >> Index: gcc/config/cil32/cil32.opt >> =================================================================== >> --- gcc/config/cil32/cil32.opt (revision 156016) >> +++ gcc/config/cil32/cil32.opt (working copy) >> @@ -77,3 +77,7 @@ >> msimd= >> Target Joined RejectNegative Var(simd_backend_str) >> -msimd=gcc|mono Select the SIMD backend >> + >> +fcil32simpcond >> +Target Report Var(flag_cil32_simp_cond) Optimization ; added to -O1 >> +Enable simplification of conditional expressions to make use of the fall >> through path when possible >> Index: gcc/config/cil32/simp-cond.c >> =================================================================== >> --- gcc/config/cil32/simp-cond.c (revision 156016) >> +++ gcc/config/cil32/simp-cond.c (working copy) >> @@ -2,7 +2,7 @@ >> conditional/unconditional branches if one of the two outgoing paths falls >> through to the next basic block. >> >> - Copyright (C) 2006-2009 Free Software Foundation, Inc. >> + Copyright (C) 2006-2010 Free Software Foundation, Inc. >> >> This file is part of GCC. >> >> @@ -25,11 +25,13 @@ >> Andrea Ornstein >> Erven Rohou >> Gabriele Svelto >> + Thierry Lafage >> >> Contact information at STMicroelectronics: >> Andrea C. Ornstein <and...@st...> >> Contact information at INRIA: >> Erven Rohou <erv...@in...> >> +Thierry Lafage <thi...@in...> >> */ >> >> #include "config.h" >> @@ -45,11 +47,13 @@ >> #include "cil-stmt.h" >> #include "cil-types.h" >> >> +extern int flag_cil32_simp_cond; >> + >> /****************************************************************************** >> * Local functions prototypes >> * >> ******************************************************************************/ >> >> -static void simplify_cond_branch (cil_stmt_iterator *, cil_stack); >> +static void simplify_cond_branch (cil_stmt_iterator *); >> static unsigned int simp_cond (void); >> static bool simp_cond_gate (void); >> >> @@ -58,17 +62,18 @@ >> ******************************************************************************/ >> >> static void >> -simplify_cond_branch (cil_stmt_iterator *csi, cil_stack stack) >> +simplify_cond_branch (cil_stmt_iterator *csi) >> { >> cil_stmt stmt; >> - cil_type_t type; >> enum cil_opcode opcode; >> tree label_then, label_else; >> - basic_block then_bb; >> + basic_block cur_bb, then_bb; >> edge true_edge, false_edge; >> >> + cur_bb = csi_bb (*csi); >> + >> /* Extract the condition's edges. */ >> - extract_true_false_edges_from_block (csi_bb (*csi), &true_edge, >> &false_edge); >> + extract_true_false_edges_from_block (cur_bb, &true_edge, &false_edge); >> label_then = gimple_block_label (true_edge->dest); >> label_else = gimple_block_label (false_edge->dest); >> >> @@ -76,37 +81,34 @@ >> >> /* Simplify the condition only if the 'then' edge can be turned into a >> fall through to the next basic block. */ >> - if (csi_bb (*csi)->next_bb == then_bb) >> + if (cur_bb->next_bb == then_bb) >> { >> - type = cil_stack_top (stack); >> - >> - if (cil_integer_p (type) || cil_pointer_p (type)) >> + switch (cil_opcode (csi_stmt (*csi))) >> { >> - switch (cil_opcode (csi_stmt (*csi))) >> - { >> - case CIL_BEQ: opcode = CIL_BNE_UN; break; >> - case CIL_BGE: opcode = CIL_BLT; break; >> - case CIL_BGE_UN: opcode = CIL_BLT_UN; break; >> - case CIL_BGT: opcode = CIL_BLE; break; >> - case CIL_BGT_UN: opcode = CIL_BLE_UN; break; >> - case CIL_BLE: opcode = CIL_BGT; break; >> - case CIL_BLE_UN: opcode = CIL_BGT_UN; break; >> - case CIL_BLT: opcode = CIL_BGE; break; >> - case CIL_BLT_UN: opcode = CIL_BGE_UN; break; >> - case CIL_BNE_UN: opcode = CIL_BEQ; break; >> - default: >> - return; /* Do nothing, we cannot change this branch. */ >> - } >> + case CIL_BEQ: opcode = CIL_BNE_UN; break; >> + case CIL_BGE: opcode = CIL_BLT; break; >> + case CIL_BGE_UN: opcode = CIL_BLT_UN; break; >> + case CIL_BGT: opcode = CIL_BLE; break; >> + case CIL_BGT_UN: opcode = CIL_BLE_UN; break; >> + case CIL_BLE: opcode = CIL_BGT; break; >> + case CIL_BLE_UN: opcode = CIL_BGT_UN; break; >> + case CIL_BLT: opcode = CIL_BGE; break; >> + case CIL_BLT_UN: opcode = CIL_BGE_UN; break; >> + case CIL_BNE_UN: opcode = CIL_BEQ; break; >> + case CIL_BRTRUE: opcode = CIL_BRFALSE; break; >> + case CIL_BRFALSE: opcode = CIL_BRTRUE; break; >> + default: >> + return; /* Do nothing, we cannot change this branch. */ >> + } >> >> - stmt = cil_build_stmt_arg (opcode, label_else); >> - csi_replace (csi, stmt); >> - csi_next (csi); >> - csi_remove (csi); >> + stmt = cil_build_stmt_arg (opcode, label_else); >> + csi_replace (csi, stmt); >> + csi_next (csi); >> + csi_remove (csi); >> >> - /* Invert the out-going edges */ >> - true_edge->flags ^= (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); >> - false_edge->flags ^= (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); >> - } >> + /* Invert the out-going edges */ >> + true_edge->flags ^= (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); >> + false_edge->flags ^= (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); >> } >> } >> >> @@ -120,23 +122,14 @@ >> basic_block bb; >> cil_stmt_iterator csi; >> cil_stmt stmt; >> - enum cil_opcode opcode; >> - cil_bb_stacks bbs; >> - cil_stack stack; >> - edge_iterator ei; >> - edge e; >> - >> - bbs = cil_bb_stacks_create (); >> >> FOR_EACH_BB (bb) >> { >> - stack = cil_stack_for_bb (bbs, bb); >> csi = csi_start_bb (bb); >> >> while (!csi_end_p (csi)) >> { >> stmt = csi_stmt (csi); >> - opcode = cil_opcode (stmt); >> >> if (cil_cond_branch_p (stmt) && !csi_one_before_end_p (csi)) >> { >> @@ -145,22 +138,15 @@ >> if (cil_opcode (csi_stmt (csi)) == CIL_BR) >> { >> csi_prev (&csi); >> - simplify_cond_branch (&csi, stack); >> + simplify_cond_branch (&csi); >> break; >> } >> } >> >> - cil_stack_after_stmt (stack, stmt); >> csi_next (&csi); >> } >> - >> - FOR_EACH_EDGE (e, ei, bb->succs) >> - { >> - cil_set_stack_for_bb (bbs, e->dest, stack); >> - } >> } >> >> - cil_bb_stacks_destroy (bbs); >> return 0; >> } >> >> @@ -169,7 +155,7 @@ >> static bool >> simp_cond_gate (void) >> { >> - return true; >> + return flag_cil32_simp_cond != 0; >> } >> >> /* Define the parameters of the cond-simp pass. */ >> Index: gcc/config/cil32/cil-stmt.c >> =================================================================== >> --- gcc/config/cil32/cil-stmt.c (revision 156016) >> +++ gcc/config/cil32/cil-stmt.c (working copy) >> @@ -1,6 +1,6 @@ >> /* CIL statements, sequences and iterators implementation. >> >> - Copyright (C) 2006-2009 Free Software Foundation, Inc. >> + Copyright (C) 2006-2010 Free Software Foundation, Inc. >> >> This file is part of GCC. >> >> @@ -23,11 +23,13 @@ >> Andrea Ornstein >> Erven Rohou >> Gabriele Svelto >> + Thierry Lafage >> >> Contact information at STMicroelectronics: >> Andrea C. Ornstein <and...@st...> >> Contact information at INRIA: >> Erven Rohou <erv...@in...> >> +Thierry Lafage <thi...@in...> >> */ >> >> #include "config.h" >> @@ -502,7 +504,9 @@ >> case CIL_BLT: >> case CIL_BLT_UN: >> case CIL_BNE_UN: >> - return true; >> + case CIL_BRFALSE: >> + case CIL_BRTRUE: >> + return true; >> >> default: >> return false; >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Gcc4cli-devel mailing list >> Gcc...@li... >> https://lists.sourceforge.net/lists/listinfo/gcc4cli-devel >> >> >> |