aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim/and-or-constant2.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-12 11:56:52 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 09:25:34 +0200
commit8ef6a1d0cac7fdbf5f0c0f70f5c3a25cc1e88670 (patch)
treec0fd4b8e050b83bde8ef113560d7d44371fe0c3d /validation/optim/and-or-constant2.c
parent4bcb69f986bc4e584cf47c0bafcaa95eafe8e710 (diff)
downloadsparse-dev-8ef6a1d0cac7fdbf5f0c0f70f5c3a25cc1e88670.tar.gz
simplify OP((x | C), K) when (C & M) == M
In an expression like OP((x | C), K), if the effective mask (M) corresponding to OP(_, K) is equal to the combined mask (C & M), then the OR operation is unneeded and can be replaced by M itself, giving: OP(M, K). In mathematical terms: 0) ((x | C) & M) = ((x & M) | (C & M)) 1) (C & M) = M 2) ((x & M) | (C & M)) = ((x & M) | M) = M and so OP((x | C), K) -> OP(M, K). For example, code like: unsigned int foo(int x) { return (x | 7) & 2; } is now simplified into: foo: ret.32 $2 which previously was not optimized foo: or.32 %r2 <- %arg1, $7 and.32 %r3 <- %r2, $2 ret.32 %r3 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim/and-or-constant2.c')
0 files changed, 0 insertions, 0 deletions