[all-commits] [llvm/llvm-project] 6ed64d: [SCEVDivision] Add SCEVDivisionPrinterPass with co...

Ryotaro Kasuga via All-commits all-commits at lists.llvm.org
Fri Aug 29 03:28:23 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6ed64df443f55b6f4cf07cc58f38b9da54176243
      https://github.com/llvm/llvm-project/commit/6ed64df443f55b6f4cf07cc58f38b9da54176243
  Author: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
  Date:   2025-08-29 (Fri, 29 Aug 2025)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolutionDivision.h
    M llvm/lib/Analysis/ScalarEvolutionDivision.cpp
    M llvm/lib/Passes/PassBuilder.cpp
    M llvm/lib/Passes/PassRegistry.def
    A llvm/test/Analysis/ScalarEvolutionDivision/sdiv.ll
    M llvm/utils/UpdateTestChecks/common.py

  Log Message:
  -----------
  [SCEVDivision] Add SCEVDivisionPrinterPass with corresponding tests (#155832)

This patch introduces `SCEVDivisionPrinterPass` and registers it under
the name `print<scev-division>`, primarily for testing purposes. This
pass invokes `SCEVDivision::divide` upon encountering `sdiv`, and prints
the numerator, denominator, quotient, and remainder. It also adds
several test cases, some of which are currently incorrect and require
fixing.

Along with that, this patch added some comments to clarify the behavior
of `SCEVDivision::divide`, as follows:

- This function does NOT actually perform the division
- Given the `Numerator` and `Denominator`, find a pair 
  `(Quotient, Remainder)` s.t.
  `Numerator = Quotient * Denominator + Remainder`
- The common condition `Remainder < Denominator` is NOT necessarily
   required
- There may be multiple solutions for `(Quotient, Remainder)`, and this
   function finds one of them
  - Especially, there is always a trivial solution `(0, Numerator)`
- The following computations may wrap
  - The multiplication of `Quotient` and `Denominator`
  - The addition of `Quotient * Denominator` and `Remainder`

Related discussion: #154745



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list