[all-commits] [llvm/llvm-project] 6da336: [SCEV] Look through multiply in computeConstantDif...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Aug 14 00:37:59 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6da3361f504495cef71caa4de4297234b6ea7fc7
      https://github.com/llvm/llvm-project/commit/6da3361f504495cef71caa4de4297234b6ea7fc7
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-08-14 (Wed, 14 Aug 2024)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/unittests/Analysis/ScalarEvolutionTest.cpp

  Log Message:
  -----------
  [SCEV] Look through multiply in computeConstantDifference() (#103051)

Inside computeConstantDifference(), handle the case where both sides are
of the form `C * %x`, in which case we can strip off the common
multiplication (as long as we remember to multiply by it for the
following difference calculation).

There is an obvious alternative implementation here, which would be to
directly decompose multiplies inside the "Multiplicity" accumulation.
This does work, but I've found this to be both significantly slower
(because everything has to work on APInt) and more complex in
implementation (e.g. because we now need to match back the new More/Less
with an arbitrary factor) without providing more power in practice. As
such, I went for the simpler variant here.

This is the last step to make computeConstantDifference() sufficiently
powerful to replace existing uses of
`cast<SCEVConstant>(getMinusSCEV())` with it.



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