Looks good to me. Please go ahead.

2012/2/13 Gang Yu <yugang...@gmail.com>:
> Hi,
>
>    Could a gatekeeper please help review the fix for
> bug948(https://bugs.open64.net/show_bug.cgi?id=948)?
>
> A cutdown case below:
>
> typedef struct chunk_t chunk_t;
> struct chunk_t {
>  unsigned char *ptr;
>  unsigned int len;
> };
> extern chunk_t chunk_empty;
> void add_sa(void *this,
>             unsigned int spi,
>             unsigned short int ipcomp,
>             unsigned short int cpi)
> {
>  char *alg_name;
>  unsigned short icv_size = 64;
>  if (ipcomp != 241 && cpi != 0)
>  {
>    add_sa(this,
>           (__extension__
>            ({ register unsigned int __v, __x =
>                ((__extension__
>                  ({ register unsigned short int __v, __x = (cpi);
>                    __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
>                    __v; })));
>              __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
>              __v; })) ,
>           ipcomp,0);
>   ipcomp = 241;
>  }
> }
> with debug compiler:
> opencc -S bug948-2.c -O3
> ### Assertion failure at line 1167 of
> /fc/proj/ctires/open64/o64guru/src/Sun/trunk/osprey/be/cg/whirl2ops.cxx:
> ### Compiler Error in file bug948-2.c during Code_Expansion phase:
> ### PREG_To_TN: non-positive preg_num
> opencc INTERNAL ERROR:
> /fc/proj/ctires/open64/o64guru/OPEN64_X86_DBG/LATEST/bits//lib/gcc-lib/x86_64-open64-linux/5.0/be
> returned non-zero status 1
>
> Analysis:
> WHIRL output after WOPT  for the unexpected part is as below, marked with
> red colors:
> ASM_STMT 4 <2,11,rorw $8, %w0> # "rorw $8, %w0" (cc) {line: 1/25}
>   BLOCK {line: 0/0}
>   END_BLOCK
>   BLOCK {line: 0/0}
>   PRAGMA 0 175 <1,7,.preg_U2> -2199023252222 (0xfffffe0000000d02) #
> ASM_CONSTRAINT, "=r", opnd:0 preg:-2 {line: 0/0}
>   END_BLOCK
>  ASM_INPUTS
>    U4U2LDID 51 <1,8,.preg_U4> T<8,.predef_U4,2> # cpi
>   ASM_INPUT opnd:1 <2,12,0> # "0"
>  END_ASM_INPUTS
>    U4U4LDID 0 <2,9,__v> T<8,.predef_U4,4>
>    U4U2LDID -2 <1,7,.preg_U2> T<7,.predef_U2,2>
>   U4COMPOSE_BITS <bofst:0 bsize:16>
>  U4STID 50 <1,8,.preg_U4> T<8,.predef_U4,1> # __v {line: 1/25}
>    U4U4LDID 50 <1,8,.preg_U4> T<8,.predef_U4,1> # __v
>   U4EXTRACT_BITS <bofst:0 bsize:16>
>  U2STID 0 <1,52,anon2> T<7,.predef_U2,2> {line: 1/26}
>  ASM_STMT 0 <2,14,bswap %0> # "bswap %0" {line: 1/27}
> Since r3866 has enabled copy-propagation into the ASM_INPUTS, there are more
> chances to do optimization for those ASM included programs.
> at O3 level, snippet before the patch:
>
>    U4U2LDID -2 <1,7,.preg_U2> T<7,.predef_U2,2>
>   U4CVTL 16
>  U4STID 51 <1,8,.preg_U4> T<8,.predef_U4,2> # __v {line: 1/25}
>   U4U4LDID 51 <1,8,.preg_U4> T<8,.predef_U4,2> # __v
>  U2STID 0 <1,52,anon2> T<7,.predef_U2,2> {line: 1/26}
>   U4U4LDID 51 <1,8,.preg_U4> T<8,.predef_U4,2> # __v
>  U4STID 50 <1,8,.preg_U4> T<8,.predef_U4,4> # __x {line: 1/26}
> is now more optimized to
>     U4U4LDID 0 <2,9,__v> T<8,.predef_U4,4>
>     U4U2LDID -2 <1,7,.preg_U2> T<7,.predef_U2,2>  # (Gang) inner mutated
> __v
>    U4COMPOSE_BITS <bofst:0 bsize:16>
> U4STID 50 <1,8,.preg_U4> T<8,.predef_U4,1> # __v {line: 1/25} # (Gang) __v
> here is the outer __v!!
>      U4U4LDID 50 <1,8,.preg_U4> T<8,.predef_U4,1> # __v
>   U4EXTRACT_BITS <bofst:0 bsize:16>
> U2STID 0 <1,52,anon2> T<7,.predef_U2,2> {line: 1/26}
>
> reduced define and use of __x, this is still right and good.
> Now, we could not assume the sink of ASM_STMT pregs as (defined
> in Find_Asm_Out_Parameter_Load/whirl2ops.cxx) in:
>
>
>       //  LDID preg_num
>       // STID
>       // ...
>       // or
>       // ...
>       //   LDID preg_num
>       //  CVT(CVTL)
>       // STID
> forms.
>
> Suggested patch:
>
> --- a/osprey/be/cg/whirl2ops.cxx
> +++ b/osprey/be/cg/whirl2ops.cxx
> @@ -114,6 +114,7 @@
>  #include "be_symtab.h"
>  #include "be_util.h"
>  #include "config_asm.h"
> +#include "wn_tree_util.h"
>  #if defined(TARG_X8664) || defined(TARG_NVISA) || defined(TARG_SL) ||
> defined(TARG_PPC32)
>  #include "cgexp_internals.h"
> @@ -6691,20 +6692,40 @@ Find_Asm_Out_Parameter_Load (const WN* stmt,
> PREG_NUM preg_num, ST** ded_st)
>  #endif
>      if (OPERATOR_is_store(WN_operator(stmt))) {
>        WN* load = WN_kid0(stmt);
> -      OPERATOR opr = WN_operator(load);
> -      if (opr == OPR_CVT || opr == OPR_CVTL) {
> -        load = WN_kid0(load);
> -        opr = WN_operator(load);
> -      }
> -      if (OPERATOR_is_load(opr) || opr == OPR_LDA) {
> -        if (WN_has_sym(load) &&
> -            WN_class(load) == CLASS_PREG &&
> -            WN_offset(load) == preg_num) {
> -          ret_load = load;
> -          break;
> +      // open64.net bug948. Since we allow copy progration into the
> +      // ASM_INPUT. More aggressive optimizations could be made.
> +      // Now, we could not always assume the "LDID preg_num" for ASM_STMTS
> output
> +      // appears in
> +      // ...
> +      //  LDID preg_num
> +      // STID
> +      // ...
> +      // or
> +      // ...
> +      //   LDID preg_num
> +      //  CVT(CVTL)
> +      // STID
> +      // ...
> +      // forms in the succeeding stmts.
> +      // Instead, we now iterate on the store kid to find the "LDID
> preg_num"
> +      // expressions.
> +      WN_TREE_CONTAINER<PRE_ORDER> lpre(load);
> +      WN_TREE_CONTAINER<PRE_ORDER> :: iterator lipre;
> +      for ( lipre = lpre.begin() ; lipre != lpre.end() ; ++ lipre) {
> +        WN* load_expr= lipre.Wn();
> +        OPERATOR opr = WN_operator(load_expr);
> +        if (OPERATOR_is_load(opr) || opr == OPR_LDA) {
> +          if (WN_has_sym(load_expr) &&
> +              WN_class(load_expr) == CLASS_PREG &&
> +              WN_offset(load_expr) == preg_num) {
> +            ret_load = load_expr;
> +            break;
> +          }
>          }
>        }
>      }
> +    if (ret_load)
> +      break;
>    }
>    if (ret_load) {
>      if (OPERATOR_has_sym(WN_operator(stmt)) &&
>
> Could a gatekeeper please help a review? thanks
>
>
> Regards
> Gang
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Open64-devel mailing list
> Open64-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/open64-devel
>



-- 
Regards,
Lai Jian-Xin

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to