diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-01-24 21:57:17 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-01-24 22:22:30 +0100 |
| commit | 36df56f0a4f87da3add3347061544f53a1865317 (patch) | |
| tree | 4e8ffcf026b20c99fc3788ca61a5d235389c7f05 /validation/optim/lsr-to-asr.c | |
| parent | 56dbccf50c2185571f34c3dfaf4753942f6a2372 (diff) | |
| download | sparse-dev-36df56f0a4f87da3add3347061544f53a1865317.tar.gz | |
simplify LSR + SEXT into ASR
A logical shift right followed by a sign extension is equivalent
to an arithmetic shift. Teach this to sparse.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim/lsr-to-asr.c')
| -rw-r--r-- | validation/optim/lsr-to-asr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/validation/optim/lsr-to-asr.c b/validation/optim/lsr-to-asr.c new file mode 100644 index 00000000..26927739 --- /dev/null +++ b/validation/optim/lsr-to-asr.c @@ -0,0 +1,27 @@ +int lsr_to_asr24(int x) +{ + return ((signed char)(((unsigned)x) >> 24)) == (x >> 24); +} + + +struct s { + int :30; + signed int f:2; +}; + +int lsr_to_asr30(int a) +{ + union { + int i; + struct s s; + } u = { .i = a }; + return u.s.f == (a >> 30); +} + +/* + * check-name: lsr-to-asr + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-returns: 1 + */ |
