[llvm] [LLVM][SCEV] Look through common multiplicand when simplifying compares. (PR #141798)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 08:59:37 PDT 2025


================
@@ -0,0 +1,378 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=indvars < %s | FileCheck %s
+
+; Verify ScalarEvolution can simplify comparisons of the form:
+;    (X * Z) icmp (Y * Z) ==> X icmp Y
+; which allows IndVarSimplify to "remove" control flow.
+
+define void @signed_icmp_mul_common_multiplicand(ptr %loc) vscale_range(1,1073741824) {
----------------
paulwalker-arm wrote:

The use of `vscale_range` here is because `llvm.vscale()` is not known positive.  Do you think it's possible to righten the definition from "returns a positive value" to "returns a signed positive value"? I would be surprised if anybody actively uses a result type that only just fits its value but it is currently possible.

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


More information about the llvm-commits mailing list