looks good to me Sun On Fri, Jul 22, 2011 at 2:30 PM, 朱庆 <zqing1...@gmail.com> wrote: > Hi all, > > Can gatekeeper help review this fix? > > The problem is, when compiling a function like: > > long fooBig(long x) { > return (x * (((long)1) << 63)); > } > > EBO will try to optimize this mul operation, in the function > Convert_Imm_Mul. At the beginning of this function, the statement > > INT64 val = imm_val < 0 ? -imm_val : imm_val; > > is trying to get the absolute value of imm_val, but in this case, > imm_val is ((long)1) << 63, which makes .imm_val is the same as > imm_val. Then, in the loop > > int power = 0; > while( val != 1 ){ > power++; > val >>= 1; > } > > val will keep being -1, which make this loop endless. > > The solution is straightforward, just to change the type of imm_val > from INT64 to UINT64. > > case: > long fooBig(long x) { > return (x * (((long)1) << 63)); > } > > Patch: > Index: osprey/be/cg/x8664/ebo_special.cxx > =================================================================== > --- osprey/be/cg/x8664/ebo_special.cxx (revision 3690) > +++ osprey/be/cg/x8664/ebo_special.cxx (working copy) > @@ -1814,7 +1814,7 @@ > OP *new_op = NULL; > const BOOL is_64bit = (TN_size(tnr) == 8); > const TYPE_ID mtype = is_64bit ? MTYPE_I8 : MTYPE_I4; > - INT64 val = imm_val < 0 ? -imm_val : imm_val; > + UINT64 val = imm_val < 0 ? -imm_val : imm_val; > OPS ops = OPS_EMPTY; > > if( imm_val == 0 ){ > @@ -1840,6 +1840,8 @@ > > bool need_an_add = false; > > + /* Check for an unsigned power of two + 1. */ > + > if( val >= 2 && > ( (val-1) & (val-2) ) == 0 ){ > val--; > @@ -1847,7 +1849,7 @@ > } > > /* Check whether it can carry an imm opnd. */ > - > + /* Check for unsigned power of two. */ > if( ( val & ( val - 1 ) ) != 0 ){ > const TOP new_top = TOP_with_Imm_Opnd( op, 1, imm_val ); > > @@ -1871,6 +1873,8 @@ > tn = tmp; > } > > + /* determine the power of val. */ > + > int power = 0; > while( val != 1 ){ > power++; > @@ -1883,7 +1887,7 @@ > Expand_Add( tnr, tnr, tn, mtype, &ops ); > } > > - if( imm_val < 0 ) > + if( imm_val < 0 && imm_val != INT64_MIN ) > Expand_Neg( tnr, tnr, mtype, &ops ); > > BB_Insert_Ops_After( OP_bb(op), op, &ops ); > > Thanks > zhuqing > > ------------------------------------------------------------------------------ > 10 Tips for Better Web Security > Learn 10 ways to better secure your business today. Topics covered include: > Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, > security Microsoft Exchange, secure Instant Messaging, and much more. > http://www.accelacomm.com/jaw/sfnl/114/51426210/ > _______________________________________________ > Open64-devel mailing list > Open64-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/open64-devel >
------------------------------------------------------------------------------ Storage Efficiency Calculator This modeling tool is based on patent-pending intellectual property that has been used successfully in hundreds of IBM storage optimization engage- ments, worldwide. Store less, Store more with what you own, Move data to the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel