diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-22 16:40:13 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-26 14:09:26 +0200 |
| commit | 9f5e91bd0cb00ab4657c4f975fa5717d478ed4b0 (patch) | |
| tree | 668d223815c8b3967681a9bacfed37e9f450dffe | |
| parent | 1ed0dfb473629202784f9701991671a6f9c6ff6e (diff) | |
| download | sparse-dev-9f5e91bd0cb00ab4657c4f975fa5717d478ed4b0.tar.gz | |
add simple testcases for internal infinite loops
The current SSA conversion kinda ignore undefined variables.
Those may then later be detected when they are part of a
LOAD + (ADD|SUB) cycle but they can also create other cycles
which are not detected.
These cycles inhibit (or uselessly complicate) lots of optimizations.
For example, code like:
and.32 %r2 <- %r1, $1
and.32 %r3 <- %r2, $1
should be simplified into:
and.32 %r3 <- %r1, $1
but this simplification would behave horribly with 'cycles' like:
and.32 %r1 <- %r1, $1
This patch add a testcase for a number a very simple situations
where such cycles can be created.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | validation/infinite-loop01.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/validation/infinite-loop01.c b/validation/infinite-loop01.c new file mode 100644 index 00000000..521cfb4d --- /dev/null +++ b/validation/infinite-loop01.c @@ -0,0 +1,54 @@ +void fnp(void) +{ + int a; + for (;;) + a += 1; +} + +void fnm(void) +{ + int a; + for (;;) + a -= 1; +} + +void fna(void) +{ + int a; + for (;;) + a &= 1; +} + +void fno(void) +{ + int a; + for (;;) + a |= 1; +} + +void fnx(void) +{ + int a; + for (;;) + a ^= 1; +} + +void fnl(void) +{ + int a; + for (;;) + a <<= 1; +} + +void fnr(void) +{ + int a; + for (;;) + a >>= 1; +} + +/* + * check-name: infinite loop 01 + * check-command: sparse -Wno-decl $file + * check-timeout: + */ |
