diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-11 14:06:53 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-22 09:25:34 +0200 |
| commit | 4bcb69f986bc4e584cf47c0bafcaa95eafe8e710 (patch) | |
| tree | d512124d0ff51b383de875646bbb77ac9c61f0fe /validation/optim | |
| parent | 05c6fad0435d07800f496a4735ea9f6532fc7be1 (diff) | |
| download | sparse-dev-4bcb69f986bc4e584cf47c0bafcaa95eafe8e710.tar.gz | |
simplify OP((x | C), K) when (C & M) == 0
In an expression like OP((x | C), K), if the inner constant
(C) and the effective mask (M) corresponding to OP(_, K) are
disjoint ((C & M) == 0), then the OR with the constant is
unneeded and can be optimized away since the constant will be
'cleared' by the mask, giving: OP(x, K)
For example, code like:
int foo(int x)
{
return (x | 0xfffff000) & 0xfff;
}
is now optimized into:
foo:
and.32 %r3 <- %arg1, $0xfff
ret.32 %r3
while previously the OR mask was not optimized away:
foo:
or.32 %r2 <- %arg1, $0xfffff000
and.32 %r3 <- %r2, $0xfff
ret.32 %r3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/and-or-bf0.c | 1 | ||||
| -rw-r--r-- | validation/optim/and-or-constant0.c | 1 |
2 files changed, 0 insertions, 2 deletions
diff --git a/validation/optim/and-or-bf0.c b/validation/optim/and-or-bf0.c index a17ff82d..cfaff4f2 100644 --- a/validation/optim/and-or-bf0.c +++ b/validation/optim/and-or-bf0.c @@ -17,7 +17,6 @@ void bar(struct s *p, int a) /* * check-name: and-or-bf0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(3): and\\. diff --git a/validation/optim/and-or-constant0.c b/validation/optim/and-or-constant0.c index e3ff0fa4..dcf440f3 100644 --- a/validation/optim/and-or-constant0.c +++ b/validation/optim/and-or-constant0.c @@ -6,7 +6,6 @@ int foo(int x) /* * check-name: and-or-constant0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: or\\. |
