aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim/and-or-bf1.c
AgeCommit message (Collapse)AuthorFilesLines
2018-08-22simplify OP(((x & M') | y), K) when (M' & M) == MLuc Van Oostenryck1-1/+0
In an expression like this, if the inner mask (M') 'covers' all the bits of the effective mask (M) corresponding to OP(_, K), IOW if (M' & M) == M, then the inner mask (M') is unneeded and can be optimized away, giving: OP((x | y), K). For example, with this simplification, code like: int foo(int x, int y) { return (((x & 0x0fffffff) | y) & 0xfff); } is now optimized into the minimal: foo: or.32 %r4 <- %arg1, %arg2 and.32 %r5 <- %r4, $0xfff ret.32 %r5 while previously, the inner mask was not optimized away: foo: and.32 %r2 <- %arg1, $0xfffffff or.32 %r4 <- %r2, %arg2 and.32 %r5 <- %r4, $0xfff ret.32 %r5 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-08-22add testcases for bitfield & AND/OR simplificationLuc Van Oostenryck1-0/+19
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>