On Wed, Jun 05, 2013 at 09:19:10PM +0200, Jakub Jelinek wrote:
> On Wed, Jun 05, 2013 at 07:57:28PM +0200, Marek Polacek wrote:
> > +  tree t, tt;
> > +  tree orig = build2 (code, TREE_TYPE (op0), op0, op1);
> > +  tree prec = build_int_cst (TREE_TYPE (op0),
> > +                        TYPE_PRECISION (TREE_TYPE (op0)));

BTW, also, to check that the shift count is not < 0 or >= prec, you can
just test that fold_convert_loc (loc, unsigned_type_for (TREE_TYPE (op1)), op1)
is LE_EXPR than precm1 (also using the unsigned type).
While optimizers often fold it to that, you might very well just create
fewer trees from the start.

The C99 undefined behavior of left signed shift can be tested by
testing if ((unsigned type for op0's type) op0) >> (precm1 - y) is
non-zero.

        Jakub

Reply via email to