> -----Original Message----- > From: Song, Ruiling > Sent: Wednesday, October 21, 2015 14:17 > To: Yang, Rong R; [email protected] > Subject: RE: [Beignet] [PATCH] LibOcl: Fix float convert to long/ulong bug. > > > > > +OVERLOADABLE DSTTYPE convert_ ## DSTTYPE ## _sat(SRCTYPE x) { \ > > > > + return x >= SRC_MAX ? DST_MAX : x <= SRC_MIN ? > (DSTTYPE)DST_MIN : > > > > (DSTTYPE)x; \ > > > > > > Why don't you use two sentences here?suppose this kind of writing > > > would generate if-else blocks? > > > Other parts LGTM. > > It is hard to use two sentences. Think about two methods: > > > > x = x >= SRC_MAX ? DST_MAX : x; > > return x <= SRC_ MIN? (DSTTYPE) DST_MIN: (DSTTYPE)x; The second > > sentences may convert SRC_MAX to DSTTYPE and return, because > SRC_MAX > > is overflow, so the value may be undefined. > > > > Another methods: > > DSTTYPE y = x >= SRC_MAX ? DST_MAX: (DSTTYPE)x; return x <= SRC_MIN ? > > (DSTTYPE) DST_MIN : (DSTTYPE)y; But in the first sentences, when > > convert x to y, the x may underflow, so the y also may be undefined. > Underflow would only occur if x<= SRC_MIN, right? > Then the final result would be DST_MIN. so the final result is also defined. > What I mean is this kind of form. This form would avoid unnecessary if-else > extra basic block generation I think. Yes, The second mothed looks ok, of course, its performance is better than previous, I will send a new version.
> > > > Don't you have other suggestion? _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
