aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/optim/and-or-trunc2.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-08 01:04:26 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 23:28:07 +0200
commit24e2b3800cc5451a509b53e8120f0e009da6f582 (patch)
treee39c718afdf4962f893d45786508dde21277a541 /validation/optim/and-or-trunc2.c
parenta4ae84a892b6e5a8b563f0bb125fcc5a3448b383 (diff)
downloadsparse-dev-24e2b3800cc5451a509b53e8120f0e009da6f582.tar.gz
simplify TRUNC((x & M') | y, N)
A N-bit truncate is not much different than ANDing with a N-bit mask and so some simplifications done for AND can also be done for TRUNC. For example for code like this: char foo(int x, int y) { return (x & 0xffff) | y; } the mask is unneeded and the function should be equivalent to: char foo(int x, int y) { return x | y; } The simplification in this patch does exactly this, giving: foo: or.32 %r4 <- %arg1, %arg2 trunc.8 %r5 <- (32) %r4 ret.8 %r5 while previously the mask was not optimized away: foo: and.32 %r2 <- %arg1, $0xffff or.32 %r4 <- %r2, %arg2 trunc.8 %r5 <- (32) %r4 ret.8 %r5 This simplification is especially important for signed bitfields because the TRUNC+ZEXT of unsigned bitfields is simplified into an OP_AND but this is, of course, not the case for the TRUNC+SEXT of signed bitfields. Do the simplification by calling simplify_mask_or(), initialy used for OP_AND, but with the effective mask corresponding to TRUNC(x, N): $mask(N). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim/and-or-trunc2.c')
-rw-r--r--validation/optim/and-or-trunc2.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/validation/optim/and-or-trunc2.c b/validation/optim/and-or-trunc2.c
index 04cb57e7..e66c1f14 100644
--- a/validation/optim/and-or-trunc2.c
+++ b/validation/optim/and-or-trunc2.c
@@ -6,7 +6,6 @@ char foo(int x, int y)
/*
* check-name: and-or-trunc2
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-pattern(1): and\\.