[llvm] [SimplifyIndVar] ICMP predicate conversion to EQ/NE (PR #144945)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 11:45:35 PST 2025


================
@@ -517,8 +516,8 @@ define i32 @test10(i32 %v) {
 ; CHECK-NEXT:    [[TMP0:%.*]] = mul nsw i64 [[INDVARS_IV]], -1
 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i64 [[TMP0]], [[SEXT]]
 ; CHECK-NEXT:    call void @consume.i1(i1 [[TMP1]])
+; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp samesign ne i64 [[INDVARS_IV_NEXT]], 11
----------------
preames wrote:

Something is highly suspicious here - nowhere in your change should we be setting samesign on the ne predate?

LangRef doesn't disallow samesign on ne/eq, but in other spots we seem to be deliberately setting it on equality comparisons in instcombine and CVP.  We should probably figure out why.

As an aside, it does look like we have a small improvement which could be separated out here.  We're not setting samesign on an predicate which is already unsigned, but both operands are known positive.  We do this in e.g. instcombine and CVP.  Doing it here seems straight forward except for a possible compile time concern?

https://github.com/llvm/llvm-project/pull/144945


More information about the llvm-commits mailing list