| Issue |
166496
|
| Summary |
miscompile when IndVarSimplify turns a float induction variable into an int?
|
| Labels |
miscompilation
|
| Assignees |
|
| Reporter |
regehr
|
IndVarSimplify can turn a float induction variable into an integer, but this isn't behavior-preserving when we get out of the range that can be represented exactly. it seems like an extra safety check on this transformation is needed.
```
~$ cat foo.c
void bar(void);
void foo(void) {
for (float f = 25.0; f <= 100000000.0; f += 17.0)
bar();
}
~$ cat bar.c
#include <stdio.h>
long cnt;
void bar(void) {
++cnt;
}
void foo(void);
int main(void) {
foo();
printf("%ld\n", cnt);
}
~$ clang -O0 foo.c bar.c && ./a.out
6188318
~$ clang -O1 foo.c bar.c && ./a.out
5882352
~$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs