On Mon, Aug 20, 2018 at 06:44:49PM +0100, Ramsay Jones wrote: > > > On 16/08/18 23:12, Luc Van Oostenryck wrote: > > If the effective mask (C & M) is different than the outer mask C, > > then this later can be replaced by the smaller (C & M), giving: > > OP((x | M'), K) with M' == (C & M). > > > > For example, code like: > > int foo(int x) > > { > > return (x | 0xfffffff0) & 0xfff; > > } > > C = 0xfffffff0, OP = &, K = 0xfff, (C & K) = 0xff0, so > OP((x | M'), K) where M' = (C & K). Indeed but I see it more as: * OP is AND/&, so M = K * C = 0xfffffff0, M = 0xfff, M' = (C & M) = 0xff0 and the simplification is: ((x | C) & M) -> ((x | M') & M) It should be noted that a better simplification here should be: ((x | C) & M) -> (x & M') but: * this is not generaly true, it would thus need a new guard * it can only be done if the OP is AND (while the whole series is about unified handling of AND/TRUNC/LSR/SHL). * at first I thought this kinf of simplification would not be worth (no intructions removed, just remove the inner mask by a smaller one) but on some code I used it was much more effective than I thought (and some others that I thought would be quite effective were not), it all depend on the exact code, of course. -- Luc