On Fri, Nov 17, 2017 at 09:45:35AM +0000, Thomas Preudhomme wrote:
> > Bootstrapped/regtested on {x86_64,i686,powerpc64le,powerpc64}-linux, ok for
> > trunk?
> >
> > The cases this patch can handle are less common than rhs_code INTEGER_CST
> > (stores of constants to adjacent memory) or MEM_REF (adjacent memory
> > copying), but are more common than the bitwise ops, during combined
> > x86_64+i686 bootstraps/regtests it triggered:
> > lrotate_expr 974 2528
> > nop_expr 720 1711
> > (lrotate_expr stands for bswap, nop_expr for identity, the first column is
> > the actual count of such new stores, the second is the original number of
> > stores that have been optimized this way).
>
> Are you saying that lrotate_expr is just the title and it also includes 32-
> and 64-bit bswap or is it only the count of lrotate_expr nodes?
The rhs_code field is magic shorthand, it could be perhaps also some enum,
the thing is that I need values for:
1) a constant satisfying rhs_valid_for_store_merging_p predicate
(usually INTEGER_CST, but it can be something different).
Right now I'm using INTEGER_CST for all those
2) a memory load; right now I'm using MEM_REF for all kinds of memory loads
3) BIT_{AND,IOR,XOR}_EXPR - these are the main reason for not using some
specialized enums, but actually a tree_code; the advantage is that then
there is no need to translate it in any way
4) bswap (any kind); the patch uses LROTATE_EXPR for that, again, like
in 1) and 2) just a placeholder
5) bswap framework determined nop; the patch uses NOP_EXPR for that; a
placeholder
Another possibility would be specialized enum, perhaps one where
SMOP_{CONSTANT,MEMORY,BSWAP,NOP} would be MAX_TREE_CODES + {1,2,3,4}
and SMOP_{AND,IOR,XOR} would be equal to BIT_{AND,IOR,XOR}_EXPR for
easier translations between.
> > @@ -1141,7 +1206,7 @@ pass_optimize_bswap::execute (function *
> > inserted smaller bswap replacements as sub-patterns, the wider
> > variant wouldn't be detected. */
> > for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);)
> > - {
> > + {
>
> Nit: could this be done when moving the code in the previous patch instead?
Sure, can do that there.
Jakub