On Wed, Dec 7, 2011 at 2:31 PM, Yiran Wang <yiran.w...@gmail.com> wrote:

> I wonder if it easily run some optimization more than wanted. GCC is not
> copy-propagating anything for -O0.
>
>
for open64, if we disable copy-propagating, we could not get the the switch
condition simplified. the suggest "q" phase is the much the same as
PREOPT_DUONLY_PHASE, except that we add DCE.

Regards
Gang


>
>
BTW, iirc, currently, wgen/vho is running GTABLE, which effectively remove
> some unreachable code.
>
> Regards,
> Yiran
>
>
> On Tue, Dec 6, 2011 at 9:27 PM, Jian-Xin Lai <laij...@gmail.com> wrote:
>
>> WGEN is not supposed to be an "optimization" phase. For the given
>> phase, VHO might be a good place to eliminate the unreachable case
>> when lowering the switch.
>>
>> 2011/12/7 Yiran Wang <yiran.w...@gmail.com>:
>> > I am not a gatekeeper, but excuse me, I wonder if why not do such kind
>> of
>> > stuff with WGEN.
>> >
>> > Regards,
>> > Yiran
>> >
>> >
>> > On Tue, Dec 6, 2011 at 6:53 PM, Gang Yu <yugang...@gmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >>    Could a gatekeeper please help review the fix for
>> >> bug798(http://bugs.open64.net/show_bug.cgi?id=798)?
>> >>
>> >> This is a bug for a long time, a typical bug case below:
>> >>
>> >> int defined_fun()
>> >> {
>> >> }
>> >>
>> >> int main()
>> >> {
>> >>
>> >>   int t;
>> >>   switch(sizeof(t))
>> >>   {
>> >>    case 4:
>> >>      defined_fun();
>> >>      break;
>> >>    default:
>> >>      undefined_fun();
>> >> }
>> >> }
>> >>
>> >> opencc -O0 b.c
>> >> /tmp/cco.c7KVi5: In function `main':
>> >> b.c:15: undefined reference to `undefined_fun'
>> >>
>> >> open64 does not invoke wopt at O0, so call to undefined_fun() is not
>> >> deleted, then the linker asserts. We may have many methods to solve
>> this
>> >> issue, hacking wgen to cut down the unreachable branch, adding
>> special dce
>> >> phase before CG expansion ..... , but the simplest way is to invoke
>> limited
>> >> wopt functionality at O0.
>> >>
>> >> This is inspired by Fred Chow and Previously Sun Chan and Suneel Jain's
>> >> comment on bug588.
>> >>
>> >> >My recommendation would be to do this kind of dead code
>> >> >elimination at -O0 in Open64. That will provide greater compatibility
>> >> >with gcc.
>> >> >- Suneel
>> >>
>> >> >can you do an experiment, please use the following options "-O0
>> >> >-phase:p" and see if the compile will go through.
>> >> >Thx!
>> >> >Sun
>> >>
>> >> We introduce a special phase q to backend, indicating invoke preopt for
>> >> dce only. the Suggest patch below:
>> >>
>> >> osprey/be/be/driver.cxx    -- 207cd21..22e93a8 100644
>> >> --- a/osprey/be/be/driver.cxx
>> >> +++ b/osprey/be/be/driver.cxx
>> >> @@ -441,6 +441,7 @@ load_components (INT argc, char **argv)
>> >>      INT phase_argc;
>> >>      char **phase_argv;
>> >> +
>> >>      if (!(Run_lno || Run_wopt || Run_preopt || Run_cg ||
>> >>           Run_prompf || Run_w2c || Run_w2f
>> >>            || Run_w2fc_early || Run_ipl))
>> >> @@ -468,6 +469,10 @@ load_components (INT argc, char **argv)
>> >>        CG_Process_Command_Line (phase_argc, phase_argv, argc, argv);
>> >>      }
>> >> +    /* run preopt for dce only also invoke preopt */
>> >> +    if (Run_preopt_dceonly)
>> >> +      Run_preopt = TRUE;
>> >> +
>> >>      if (Run_wopt || Run_preopt || Run_lno || Run_autopar) {
>> >>        Get_Phase_Args (PHASE_WOPT, &phase_argc, &phase_argv);
>> >>  #if !defined(BUILD_FAST_BIN)
>> >> osprey/be/be/driver_util.cxx    -- e8f58f9..d5c4698 100644
>> >> --- a/osprey/be/be/driver_util.cxx
>> >> +++ b/osprey/be/be/driver_util.cxx
>> >> @@ -481,6 +481,12 @@ Process_Command_Line (INT argc, char **argv)
>> >>             if (strcmp (myname, "preopt") == 0)
>> >>                 Run_preopt = TRUE;
>> >>             break;
>> >> +        case 'q':
>> >> +            if (strcmp (myname, "preopt") == 0) {
>> >> +              Run_preopt = TRUE;
>> >> +              Run_preopt_dceonly = TRUE;
>> >> +            }
>> >> +            break;
>> >>         case 'c':
>> >>             if (strcmp (myname, "cg") == 0)
>> >>                 Run_cg = TRUE;
>> >> osprey/be/opt/opt_main.cxx    -- 4b8957c..a7e4679 100644
>> >> --- a/osprey/be/opt/opt_main.cxx
>> >> +++ b/osprey/be/opt/opt_main.cxx
>> >> @@ -731,6 +731,51 @@ private:
>> >>        WOPT_Enable_Combine_Operations = FALSE;
>> >>        WOPT_Enable_SLT = FALSE;
>> >>        OPT_Enable_WHIRL_SSA = FALSE;
>> >> +      if (Run_preopt_dceonly) {
>> >> +          WOPT_Enable_Add_Do_Loop_Info =
>> >> +          WOPT_Enable_Add_Label_Loop_Info =
>> >> +          WOPT_Enable_Aggressive_dce =
>> >> +          WOPT_Enable_Aggressive_Code_Motion =
>> >> +          WOPT_Enable_Alias_Classification =
>> >> +          WOPT_Enable_Alias_Class_Fortran_Rule =
>> >> +          WOPT_Enable_Combine_Operations =
>> >> +          WOPT_Enable_Compare_Simp =
>> >> +          WOPT_Enable_CRSIMP =
>> >> +          WOPT_Enable_DCE_Alias =
>> >> +          WOPT_Enable_Edge_Placement =
>> >> +          WOPT_Enable_Exp_PRE =
>> >> +          WOPT_Enable_Fold2const =
>> >> +          WOPT_Enable_LNO_Copy_Propagate =
>> >> +          WOPT_Enable_FSA =
>> >> +          WOPT_Enable_Goto =
>> >> +          WOPT_Enable_Input_Prop =
>> >> +          WOPT_Enable_Itself_Prop =
>> >> +          WOPT_Enable_Ivar_Common =
>> >> +          WOPT_Enable_IVE =
>> >> +          WOPT_Enable_IVR =
>> >> +          WOPT_Enable_Ldx =
>> >> +          WOPT_Enable_Load_PRE =
>> >> +          WOPT_Enable_Local_Rvi =
>> >> +          WOPT_Enable_Output_Copy =
>> >> +          WOPT_Enable_Parm =
>> >> +          WOPT_Enable_Phi_Simp =
>> >> +          WOPT_Enable_RVI =
>> >> +          WOPT_Enable_SLT =
>> >> +          WOPT_Enable_Store_PRE =
>> >> +          WOPT_Enable_SSA_PRE =
>> >> +          WOPT_Enable_Vsym_Unique =
>> >> +          OPT_Enable_WHIRL_SSA =
>> >> +          WOPT_Enable_WOVP =
>> >> +          Enable_WN_Simp =                     // disable WHIRL
>> >> simplifier
>> >> +          // WOPT_Enable_Zero_Version =
>> >> +          WOPT_Enable_Tail_Recur =
>> >> +          FALSE;
>> >> +
>> >> +        WOPT_Enable_Verify = 1;
>> >> +        WOPT_Enable_DCE = WOPT_Enable_Copy_Propagate = TRUE;
>> >> +
>> >> +
>> >> +      }
>> >>        break;
>> >>      } // switch
>> >>      WOPT_Enable_Ldx = Indexed_Loads_Allowed;
>> >> osprey/common/com/config.cxx    -- c972676..387f9c1 100644
>> >> --- a/osprey/common/com/config.cxx
>> >> +++ b/osprey/common/com/config.cxx
>> >> @@ -621,6 +621,8 @@ static OPTION_DESC Options_PHASE[] = {
>> >>        &Run_wopt,       NULL},
>> >>      { OVK_BOOL,        OV_INTERNAL,    FALSE, "preopt", "p",    0, 0,
>> 0,
>> >>        &Run_preopt,     NULL},
>> >> +    { OVK_BOOL,        OV_INTERNAL,    FALSE, "q",       "",    0, 0,
>> 0,
>> >> +      &Run_preopt_dceonly,     NULL},
>> >>      { OVK_BOOL,        OV_INTERNAL,    FALSE, "cg",      "c",   0, 0,
>> 0,
>> >>        &Run_cg, NULL},
>> >>      { OVK_BOOL,        OV_INTERNAL,    FALSE, "clist",  NULL,   0, 0,
>> 0,
>> >> @@ -998,6 +1000,7 @@ BOOL Enable_EBO_Post_Proc_Rgn = TRUE ;
>> >>  BOOL Run_lno = FALSE;              /* run loop-nest optimizer */
>> >>  BOOL Run_wopt = FALSE;             /* run WHIRL global optimizer */
>> >>  BOOL Run_preopt = FALSE;           /* run WHIRL preopt optimizer */
>> >> +BOOL Run_preopt_dceonly = FALSE;        /* run WHIRL preopt only for
>> dce
>> >> */
>> >>  BOOL Run_ipl = FALSE;              /* run procedure summary phase  */
>> >>  BOOL Run_cg = FALSE;               /* run code generator */
>> >>  BOOL Run_w2c = FALSE;              /* run whirl2c */
>> >> osprey/common/com/config.h    -- 3df7f78..9bdab1d 100644
>> >> --- a/osprey/common/com/config.h
>> >> +++ b/osprey/common/com/config.h
>> >> @@ -732,6 +732,7 @@ extern BOOL Run_lego;               /* run
>> >> lego-lowering */
>> >>  extern BOOL Run_lego_given;         /* was run lego-lowering
>> given/not */
>> >>  extern BOOL Run_wopt;              /* run WHIRL global optimizer */
>> >>  extern BOOL Run_preopt;                    /* run WHIRL preopt
>> optimizer
>> >> */
>> >> +extern BOOL Run_preopt_dceonly;     /* run WHIRL preopt only for dce
>> */
>> >>  extern BOOL Run_cg;                /* run code generator */
>> >>  extern BOOL Run_w2c;               /* run whirl2c */
>> >>  extern BOOL Run_w2f;               /* run whirl2f */
>> >> osprey/driver/special_options.c    -- a65a384..abe35f5 100644
>> >> --- a/osprey/driver/special_options.c
>> >> +++ b/osprey/driver/special_options.c
>> >> @@ -416,13 +416,19 @@ add_special_options (void)
>> >>              *
>> >>              *                          -O0/-O1 -O2             -O3
>> >>              *                          ===========================
>> >> -            *          .B,.I,.P:       cg      wopt/cg
>> >> lno/wopt/cg
>> >> -            *          .N:             cg      wopt/cg         wopt/cg
>> >> +            *          .B,.I:          q/cg    wopt/cg
>> >> lno/wopt/cg
>> >> +             *          .P:             cg      wopt/cg
>> >> lno/wopt/cg
>> >> +            *          .N:             q/cg    wopt/cg         wopt/cg
>> >>              *          .O:             cg      cg              cg
>> >> +             * q means preopt for dce only.
>> >>              */
>> >>             if (source_kind == S_O)
>> >>                 warning("compiles of WOPT-generated .O files will
>> usually
>> >> fail due to missing state information");
>> >>             if (olevel <= 1 || source_kind == S_O)
>> >> +              if ( source_kind != S_P )
>> >> +              /* bug798 open64.net. add phase q for DCE on O0 .I .B*/
>> >> +                flag = add_string_option(O_PHASE_, "q:c");
>> >> +              else
>> >>                 flag = add_string_option(O_PHASE_, "c");
>> >>             else if (olevel == 2 || source_kind == S_N)
>> >>                 flag = add_string_option(O_PHASE_, "w:c");
>> >>
>> >> could a gatekeeper pleae help a review? thanks
>> >>
>> >>
>> >> Regards
>> >> Gang
>> >>
>> >>
>> >>
>> ------------------------------------------------------------------------------
>> >> Cloud Services Checklist: Pricing and Packaging Optimization
>> >> This white paper is intended to serve as a reference, checklist and
>> point
>> >> of
>> >> discussion for anyone considering optimizing the pricing and packaging
>> >> model
>> >> of a cloud services business. Read Now!
>> >> http://www.accelacomm.com/jaw/sfnl/114/51491232/
>> >> _______________________________________________
>> >> Open64-devel mailing list
>> >> Open64-devel@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/open64-devel
>> >>
>> >
>> >
>> >
>> ------------------------------------------------------------------------------
>> > Cloud Services Checklist: Pricing and Packaging Optimization
>> > This white paper is intended to serve as a reference, checklist and
>> point of
>> > discussion for anyone considering optimizing the pricing and packaging
>> model
>> > of a cloud services business. Read Now!
>> > http://www.accelacomm.com/jaw/sfnl/114/51491232/
>> > _______________________________________________
>> > Open64-devel mailing list
>> > Open64-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/open64-devel
>> >
>>
>>
>>
>> --
>> Regards,
>> Lai Jian-Xin
>>
>
>
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to