Move some bit and binary optimizations in simplify and match
Richard Biener
richard.guenther@gmail.com
Wed Oct 14 10:09:00 GMT 2015
On Wed, Oct 14, 2015 at 7:39 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>
> +(simplify
> + (plus (convert? @0) (convert? (xdivamulminusa @0 @1)))
> + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
> + && tree_nop_conversion_p (type, TREE_TYPE (@0)))
> + (trunc_mod (convert @0) (convert @1))))
>
> See PR 67953.
Please drop xdivamulminusa. It was a bad idea of mine, just add two patterns.
> +(match (abitandnotb @0 @1)
> + (bit_and:c @0 (bit_not INTEGER_CST@1)))
>
> Does that work?
No. Please drop these helpers and instead duplicate the patterns.
>
> +/* Fold (a * (1 << b)) into (a << b) */
> +(simplify
> + (mult:c @0 (convert? (lshift integer_onep@1 @2)))
> + (if (! FLOAT_TYPE_P (type)
> + && tree_nop_conversion_p (type, TREE_TYPE (@2)))
> + (lshift @0 (convert @2))))
>
> You don't need/want to convert @2 (fold-const doesn't convert, does it?),
> and you don't need to check for tree_nop_conversion_p.
I think for long x and x * (long)(1u << b) you need to do because the
result for b == 33 would be different. Indeed you don't need the convert on @2.
Richard.
>
> --
> Marc Glisse
More information about the Gcc-patches
mailing list