The simple reason may be F8 is the largest type for sqrt. Another solution may be to set the type to the operand. But I simply want to make it consistent to other intrinsics with similar issue (they solve it in this way).
Best Regards, yiran On Fri, Sep 10, 2010 at 3:14 PM, Sun Chan <sun.c...@gmail.com> wrote: > why is F8 the default, but not others? > Sun > > On Sat, Sep 11, 2010 at 6:08 AM, Yiran Wang <yiran.w...@gmail.com> wrote: > > Hi Sun, > > Sure. > > The situation is as following. > > There is implementation of the intrinsic "sqrt", for a number of types, > such > > as F4, F8, and so on. While, the compiler want to determine the exact > type > > of the sqrt by context. For example, > > double a, b; > > a = sqrt(b); > > Then the type is F8. > > Usually it works, but for the following code: > > double x; > > int y; > > y = sqrt(x*x)>1?1:0; > > The result of sqrt is used by the > operator. While, the operator > would > > like to promote the type of the two operands, so they match. So it would > not > > provide type information for the sqrt intrinsic. So, the compiler simply > > generate something like > > VSTID... > > VSQRT ... > > The change is to set default type to F8, for such case. > > Best Regards, > > yiran > > > > On Fri, Sep 10, 2010 at 2:54 PM, Sun Chan <sun.c...@gmail.com> wrote: > >> > >> please give a brief description of the bug. Or a simple test case. The > >> portion of code change is not enough for me to tell why F8 is the > >> right type, but not, say, F4, or V8.... > >> Sun > >> > >> On Sat, Sep 11, 2010 at 2:58 AM, Yiran Wang <yiran.w...@gmail.com> > wrote: > >> > Hi All, > >> > Could a gatekeeper please review it? > >> > Simply, the ret_mtype should be reset automatically, if it is void. > This > >> > is > >> > already done for a number of other intrinsics. > >> > The bug is triggered when the combination of > and ?: operator is > used, > >> > as > >> > the result type is not set by parent of the intrinsic. > >> > Best Regards, > >> > yiran > >> > > >> > Index: wgen_expr.cxx > >> > =================================================================== > >> > --- wgen_expr.cxx (revision 3338) > >> > +++ wgen_expr.cxx (working copy) > >> > @@ -8153,6 +8153,7 @@ > >> > #ifndef TARG_MIPS // MIPS needs quad emulation for sqrt operation > >> > case GSBI_BUILT_IN_SQRTL: > >> > #endif > >> > + if (ret_mtype == MTYPE_V) ret_mtype = MTYPE_F8; > >> > if (! gs_flag_errno_math(program)) { > >> > arg_wn = WGEN_Expand_Expr (gs_tree_value > >> > (gs_tree_operand > >> > (exp, 1))); > >> > wn = WN_CreateExp1 (OPR_SQRT, ret_mtype, MTYPE_V, > >> > arg_wn); > >> > > >> > > >> > > ------------------------------------------------------------------------------ > >> > Start uncovering the many advantages of virtual appliances > >> > and start using them to simplify application deployment and > >> > accelerate your shift to cloud computing > >> > http://p.sf.net/sfu/novell-sfdev2dev > >> > > >> > _______________________________________________ > >> > Open64-devel mailing list > >> > Open64-devel@lists.sourceforge.net > >> > https://lists.sourceforge.net/lists/listinfo/open64-devel > >> > > >> > > > > > >
------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel