Issue with [InstCombine] Canonicalize range test idiom [D113366]

[AMD Official Use Only]

Hi, and

The above change causes a soft hang for the below IR in InstCombine Transform.

define i32 @p0(i32 %CF_init) {
%t0 = add i32 %CF_init, -3
%t1 = icmp ugt i32 %t0, 1
%t2 = select i1 %t1, i32 -3, i32 1
ret i32 %t2

tryToReuseConstantFromSelectInComparison() from InstCombineSelect.cpp will replace select with inverse icmp and select. 1376301c8727 change when it sees a icmp ugt will replace with icmp ult. InstCombinerImpl::run() in InstructionCombining.cpp, will run these transforms in a loop and it never ends. This is causing soft hang.

icmp ugt is always transformed to icmp ult. Issue is with this transform. Commenting out the change fixes the soft hang issue.
Any suggestion on other ways of fixing this in InstructionCombining transform pass?


This problem was also reported as:
…and should be fixed with: