Two comments:
1. This patch is not generic enough. If the type tenths is shor or
other, it still fails. I think there are some other case (the parent
is not STID) also causes the same problem.
2. The function prototype change can be applied to all architecture.

2012/2/24 Gang Yu <[email protected]>:
> Hi,
>
>   Could a gatekeeper please help review the fix for
> bug952(http://bugs.open64.net/show_bug.cgi?id=952)?
>
> Cut-down case please have a look at the attachment:
>
> http://bugs.open64.net/attachment.cgi?id=511
>
> opencc asserts:
>
> ### Assertion failure at line 6888 of
> /fc/home/yug/open64/osprey/be/cg/x8664/expand.cxx:
> ### Compiler Error in file bug952.c during Code_Expansion phase:
> ### Exp_COPY: src or target TN pair missing
>
> analysis:
>
> The snippet to trigger the bug:
>
>       unsigned long long r10 = (n % divisor) * 10;
>       tenths = r10 / divisor;
> ...
>       tenths = r10/base;
>
>
> in whirl format
> ...
>   U8U8LDID 78 <1,9,.preg_U8> T<9,.predef_U8,4> # __udivdi3.return
>  U4STID 72 <1,8,.preg_U4> T<4,.predef_I4,4> # tenths {line: 1/27}
>
> ....
>   U4U4LDID 64 <1,8,.preg_U4> T<8,.predef_U4,4> # <preg>
>   U4LOWPART
>  U4STID 72 <1,8,.preg_U4> T<4,.predef_I4,4> # tenths {line: 1/40}
>
> preg 72 is expanded to pair (TN179,TN180), so U4STID 72 does require pair TN
> copy,  while TN189(the source) does not have the pair TN, which cause the
> assertion.
>
> Solution:
> make preg72 be holded by a non-pair TN, so
>
>   U8INTRINSIC_OP 2 <792,UDIVDI3> 0
>  U4STID 72 <1,8,.preg_U4> T<4,.predef_I4,4> # tenths {line: 1/27}
>
> do only single (non-paired) expand copy if there is U4STID in -m32 , even
> the source in U8*** form.
>
> patch below:
> index 38ef367..d698937 100644
> --- a/osprey/be/cg/whirl2ops.cxx
> +++ b/osprey/be/cg/whirl2ops.cxx
> @@ -1943,8 +1943,13 @@ Find_PREG_For_Symbol (const ST *st)
>  extern void Expand_Copy_Extension (TN *result, TN *src, TYPE_ID mtype, BOOL
> signed_extension, OPS *ops);
>  #endif
>
> +#ifdef TARG_X8664
> +TN *
> +Handle_LDID (WN* ldid, WN* parent, TN * result, OPCODE opcode)
> +#else
>  TN *
>  Handle_LDID (WN *ldid, TN *result, OPCODE opcode)
> +#endif
>  {
>    if (ST_assigned_to_dedicated_preg(WN_st(ldid))) {
>         // replace st with dedicated preg
> @@ -2026,7 +2031,14 @@ Handle_LDID (WN *ldid, TN *result, OPCODE opcode)
>          }
>        }
>  #elif  defined(TARG_X8664)
> -      if( OP_NEED_PAIR( ST_mtype(WN_st(ldid) ) ) ){
> +      if( OP_NEED_PAIR( ST_mtype(WN_st(ldid))) &&
> +          // open64.net bug952
> +          // For m32, dont' copy TN pair for I8I8LDID for the case
> +          //   U8U8LDID
> +          // U4STID xx <preg>
> +          !(parent != NULL &&
> +           (WN_opcode(parent) == OPC_U4STID ||
> +            WN_opcode(parent) == OPC_I4STID))) {
>          Expand_Copy( result, ldid_result, ST_mtype(WN_st(ldid)), &New_OPs
> );
>        } else {
>          Exp_COPY (result, ldid_result, &New_OPs);
> @@ -4966,8 +4978,11 @@ Expand_Expr (WN *expr, WN *parent, TN *result)
>    switch (opr) {
>
>    case OPR_LDID:
> +#ifdef TARG_X8664
> +    return Handle_LDID (expr, parent, result, opcode);
> +#else
>      return Handle_LDID (expr, result, opcode);
> -
> +#endif
>    case OPR_LDBITS:
>      return Handle_LDBITS (expr, result, opcode);
>
> TIA for review.
>
> Regards
> Gang
>
> ------------------------------------------------------------------------------
> 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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to