[PATCH] D129753: [SCEV] Prove condition invariance via context
Mikael Holmén via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 01:41:12 PDT 2022
uabelho added a comment.
Hello,
I think I'm seeing a miscompile with this patch.
Reproduce with:
opt --passes="indvars" bbi-72689.ll -S -o -
indvars does
< %cmp22.not.i = icmp ult i32 %storemerge13.i, 2
---
> %cmp22.not.i = icmp ult i32 0, 2
which I think is incorrect.
We have
[...]
%storemerge13.i = phi i32 [ 0, %entry ], [ %dec.i, %for.inc32.i ]
%cmp22.not.i = icmp ult i32 %storemerge13.i, 2
[...]
%dec.i = add i32 %storemerge13.i, -1
[...]
so we start at 0, then add -1 so we get -1, and then do an ult compare between -1 (0xffffffff) and 2, which I suppose should be false?
But indvars changes the compare to icmp ult i32 0, 2 which is always true?
The end result is that the function loops forever instead of returning -1.
F24200119: bbi-72689.ll <https://reviews.llvm.org/F24200119>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129753/new/
https://reviews.llvm.org/D129753
More information about the llvm-commits
mailing list