diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-03-11 01:34:19 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-03-13 11:26:11 +0100 |
| commit | 32f1c1c24386e9379a8a7b3148d876e0a7cf027e (patch) | |
| tree | 1c6c33187971dd095ae8d9c69bfcf4170c83bb11 /validation | |
| parent | eb4cdd21b7d0cedbbeff7f70e24473706ccce5a6 (diff) | |
| download | sparse-dev-32f1c1c24386e9379a8a7b3148d876e0a7cf027e.tar.gz | |
canonicalize ((x & M) == M) --> ((x & M) != 0) when M is a power-of-2
and same for its dual: ((x & M) != M) --> ((x & M) == 0)
Beside the canonicalization itself, these simplifications are
useful because the compare against 0 can often be further
simplified (for example when it is used by OP_CBR or OP_SELECT).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/optim/cmp-and-pow2.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/validation/optim/cmp-and-pow2.c b/validation/optim/cmp-and-pow2.c new file mode 100644 index 00000000..01ba2537 --- /dev/null +++ b/validation/optim/cmp-and-pow2.c @@ -0,0 +1,12 @@ +#define M 32 + +_Bool eq(int a) { return ((a & M) != M) == ((a & M) == 0); } +_Bool ne(int a) { return ((a & M) == M) == ((a & M) != 0); } + +/* + * check-name: cmp-and-pow2 + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-returns: 1 + */ |
