aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim/and-or-bf2.c
AgeCommit message (Collapse)AuthorFilesLines
2018-08-22simplify OP(((x & M') | y), K) when (M' & M) != M'Luc Van Oostenryck1-1/+0
Currently, in simplify_mask_or_and(), only the cases where (M' & M) == 0 or (M' & M) == M are simplified. However, if the combined mask (M' & M) is different than the original inner mask (M'), this inner mask can be replaced by the smaller combined one, giving: OP(((x & (M' & M)) | y), K). For example, code like: int foo(int x, int y) { return (((x & 0xfffffff0) | y) & 0xfff); } is now simplified into: foo: and.32 %r2 <- %arg1, $0xff0 or.32 %r4 <- %r2, %arg2 and.32 %r5 <- %r4, $0xfff ret.32 %r5 while previously, the mask was not reduced: foo: and.32 %r2 <- %arg1, $0xfffffff0 ... Note: this is not a very effective simplification like directly removing an instruction, nevertheless the smaller mask can trigger other simplifications and may also be advantageous for a subsequent code generation phase. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-08-22add testcases for bitfield & AND/OR simplificationLuc Van Oostenryck1-0/+28
The extraction & insertion of bitfields is made of relatively complex combinations of SHL/LSR/AND/OR and TRUNC/ZEXT/SEXT. Add a few testcases showing the effectiveness of their simplification and to catch possible future regressions. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>