[llvm] [LV] Use SCEV to check if minimum iteration check is known. (PR #111310)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 04:58:08 PDT 2024


================
@@ -1668,8 +1668,7 @@ define i32 @fcmp_0_sub_select1(ptr noalias %x, i32 %N) nounwind readonly {
 ; CHECK:       [[FOR_HEADER]]:
 ; CHECK-NEXT:    [[ZEXT:%.*]] = zext i32 [[N]] to i64
 ; CHECK-NEXT:    [[TMP0:%.*]] = sub i64 0, [[ZEXT]]
-; CHECK-NEXT:    [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP0]], 4
-; CHECK-NEXT:    br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
+; CHECK-NEXT:    br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
----------------
fhahn wrote:

Agreed, might be worth fixing independently.

The simplification is fine for the input I think, BTC is `(-1 + (-1 * (zext i32 %N to i64))<nsw>)<nsw>`, trip count with info from the dominating loop guard is `(-1 * (zext i32 (1 smax %N) to i64))<nsw>` which should be u>= 4. https://llvm.godbolt.org/z/1EMWbGb81

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


More information about the llvm-commits mailing list