Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-11-05 Thread Richard Biener
On Thu, Nov 5, 2015 at 2:26 PM, Alan Lawrence wrote: > On 3 November 2015 at 11:35, Richard Biener > wrote: >> >> I think this should simply re-write A << B to (type) (unsigned-type) A >> * (1U << B). >> >> Does that then still vectorize the signed case? > > I didn't realize our representation o

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-11-05 Thread Alan Lawrence
On 3 November 2015 at 11:35, Richard Biener wrote: > > I think this should simply re-write A << B to (type) (unsigned-type) A > * (1U << B). > > Does that then still vectorize the signed case? I didn't realize our representation of chrec's could express that. Yes, it does - thanks! (And the avx51

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-11-03 Thread Richard Biener
On Tue, Nov 3, 2015 at 11:15 AM, Alan Lawrence wrote: > On 27/10/15 22:27, H.J. Lu wrote: >> >> It caused: >> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68112 > > Bah :(. > > So yes, in general case, we can't rewrite (a << 1) to (a * 2) as for signed > types (0x7f...f) << 1 == -2 whereas (0x7

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-11-03 Thread Alan Lawrence
On 27/10/15 22:27, H.J. Lu wrote: > > It caused: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68112 Bah :(. So yes, in general case, we can't rewrite (a << 1) to (a * 2) as for signed types (0x7f...f) << 1 == -2 whereas (0x7f...f * 2) is undefined behaviour. Oh well :(... I don't have a real

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-10-27 Thread H.J. Lu
On Tue, Oct 27, 2015 at 5:40 AM, Alan Lawrence wrote: > --in-reply-to > > > On 26/10/15 08:58, Richard Biener wrote: >> >> On Fri, Oct 23, 2015 at 5:15 PM, Alan Lawrence wrote: >>> + chrec2 = fold_build2 (LSHIFT_EXPR, TREE_TYPE (rhs1), >>> + build_int_cst (TREE_TY

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-10-27 Thread Alan Lawrence
--in-reply-to On 26/10/15 08:58, Richard Biener wrote: > > On Fri, Oct 23, 2015 at 5:15 PM, Alan Lawrence wrote: >> + chrec2 = fold_build2 (LSHIFT_EXPR, TREE_TYPE (rhs1), >> + build_int_cst (TREE_TYPE (rhs1), 1), > > 'type' instead of TREE_TYPE (rhs1) I presume y

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-10-26 Thread Richard Biener
On Fri, Oct 23, 2015 at 5:15 PM, Alan Lawrence wrote: > On 19/10/15 12:49, Richard Biener wrote: > >> Err, you should always do the shift in the type of rhs1. You should also >> avoid the chrec_convert of rhs2 above for shifts. > > Err, yes, indeed. Needed to keep the chrec_convert before the >

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-10-23 Thread Alan Lawrence
On 19/10/15 12:49, Richard Biener wrote: > Err, you should always do the shift in the type of rhs1. You should also > avoid the chrec_convert of rhs2 above for shifts. Err, yes, indeed. Needed to keep the chrec_convert before the chrec_fold_multiply, and the rest followed. How's this? Bootstr

Re: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant

2015-10-19 Thread Richard Biener
On Fri, Oct 16, 2015 at 5:25 PM, Alan Lawrence wrote: > This lets the vectorizer handle some simple strides expressed using left-shift > rather than mul, e.g. a[i << 1] (whereas previously only a[i * 2] would have > been handled). > > This patch does *not* handle the general case of shifts - neith