[llvm] [SCEVExpander] Don't expand a UDiv with a possibly-poison divisor (PR #202378)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 01:26:59 PDT 2026


================
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=indvars < %s | FileCheck %s
+
+; Reduced from https://github.com/llvm/llvm-project/issues/202028.
+
+target triple = "x86_64-unknown-linux-gnu"
----------------
lijinpei-amd wrote:

  The X86 triple was only there to make rewriteLoopExitValues consider the rewrite profitable. Under the default OnlyCheapRepl, it only hoists the exit value when isHighCostExpansion is within budget (4), and the cost hinges on the udiv:
  
  - With the triple, X86TTIImpl::getArithmeticInstrCost reports 1 → under budget → hoisted (the bug).
  - Without it, TargetTransformInfoImplBase::getArithmeticInstrCost reports 4 (TCC_Expensive) → over budget → not exercised.

  I now force it with -replexitval=always instead, so the test needs no triple and moves out of X86/.


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


More information about the llvm-commits mailing list