New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[InstCombine] Infinite loop in InstCombine on smax+cmp+select sequence #50761
Comments
Reduced: define i32 @infloop(i32 %x, double %d, i64 %a) { There are opposing transforms somewhere under visitICmp. I'll try to find and fix. |
https://reviews.llvm.org/rGb267d3ce8def Leaving open as candidate for blocking 13.0 release. |
If backporting, we'll also need this patch to avoid breaking tests: |
And I almost forgot already, but that one was on top of adding tests: |
Thanks for the quick response, Sanjay. I appreciate it. |
Some day, we'll canonicalize to the intrinsics and get out of this mess. :) Just curious - did this show up in real code or was it found by fuzzing of some kind? |
It showed up in a handful of SPEC codes (e.g. omnetpp, wrf, blender). We don't use the Clang frontend though. And we also do heavy vectorization before opt is called. |
Thanks - that sounds like good incentive to try to backport this to the release. After reviewing my patch, I think that we do not need to backport the changes to InstSimplify to get the InstCombine fix to patch cleanly. So to be clear, I expect that b267d3c can be backported alone if that is viewed as a less risky/more direct bug fix. But taking 9b942a5 and e260e10 (InstSimplify) would get us more in line with the current 'main' branch. |
Merged: 5b60faa |
mentioned in issue #51489 |
Extended Description
The following test case is tripping an infinite loop in InstCombine. I've been unable to track down the root cause yet.
This issue was found in release/13.x, but Godbolt shows it failing in trunk as well.
https://godbolt.org/z/xKasbGheK
; RUN: opt -O3 -instcombine -S < %s
define i64 @infloop(double %d, i64 %a) {
%1 = fptosi double %d to i32
%2 = call i32 @llvm.smax.i32(i32 %1, i32 0)
%3 = icmp slt i32 %2, 2
%4 = zext i1 %3 to i32
%5 = select i1 %3, i32 %2, i32 1
%6 = zext i32 %5 to i64
%7 = mul i64 %6, 4
%8 = add i64 %a, %7
ret i64 %8
}
The text was updated successfully, but these errors were encountered: