[llvm] [LV] Rewrite UDiv A, B -> UDiv A, UMax(B, 1) in trip counts if needed. (PR #92177)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 14:30:04 PDT 2024


================
@@ -527,6 +528,76 @@ exit:
   ret i64 %p
 }
 
+define i64 @multi_exit_4_exit_count_with_udiv_by_frozen_value_in_latch(ptr %dst, i64 %N) {
----------------
efriedma-quic wrote:

Yes, this is what I was thinking, roughly.

> I am not sure if the divisor being poison in @multi_exit_4_exit_count_with_udiv_by_value_in_latch actually needs freezing

We could probably refine this in SCEVExpander if we end up generating a bunch of freeze in inconvenient places (basically, make a map of SCEVUnknowns which are used without freezing them, and then don't freeze if we see them elsewhere).

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


More information about the llvm-commits mailing list