aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim/and-or-bfx.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-08 00:48:06 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 09:25:34 +0200
commit8b8a5e5501bb130900f0007126d283119512b286 (patch)
tree38048aaa11a59654a4ecce5e8bb93558ad3bb50a /validation/optim/and-or-bfx.c
parent6faa3df7a00349041436b6b17a3891425f0b8928 (diff)
downloadsparse-dev-8b8a5e5501bb130900f0007126d283119512b286.tar.gz
allow simplification of OP(((x & y) | (a & M')), K)
In simplify_mask_or(), two calls to simplify_mask_or_and() are made: one for each operand of the OR instruction. These two calls are guarded by a test checking the presence of the AND instruction. If it is the case for the first operand, the second operand is never considered for simplification, even if no simplifications have been made. Fix this by testing the return value of simplify_and_or_mask() and let's do the second call if no simplifications could be done in the first one. For example, code like: int foo(int x, int y, int a) { return ((a & 0xf000) | (x & y)) & 0x0fff; } was expectedly simplified into: foo: and.32 %r5 <- %arg1, %arg2 and.32 %r7 <- %r5, $0xfff ret.32 %r7 while the same code with the operands of the OR swapped was not: int foo(int x, int y, int a) { return ((x & y) | (a & 0xf000)) & 0x0fff; } resulted in the non-optimized: foo: and.32 %r3 <- %arg1, %arg2 and.32 %r5 <- %arg3, $0xf000 or.32 %r6 <- %r3, %r5 and.32 %r7 <- %r6, $0xfff ret.32 %r7 but now the simplification can also be done: foo: and.32 %r3 <- %arg1, %arg2 and.32 %r7 <- %r3, $0xfff ret.32 %r7 Note: it would be simpler to unconditionally do both calls but this is unsafe because some of the concerned instructions, needed in the second call, could have been simplified away in the first one. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim/and-or-bfx.c')
-rw-r--r--validation/optim/and-or-bfx.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/validation/optim/and-or-bfx.c b/validation/optim/and-or-bfx.c
index ed04e2d3..57a54cf5 100644
--- a/validation/optim/and-or-bfx.c
+++ b/validation/optim/and-or-bfx.c
@@ -11,7 +11,6 @@ void foo(struct s *p, int a, int b)
/*
* check-name: and-or-bfx
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-pattern(2): and\\.