[all-commits] [llvm/llvm-project] 4653f9: [SCEV] Introduce SCEVUse, use it instead of const ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Oct 9 06:35:21 PDT 2024


  Branch: refs/heads/users/fhahn/scevuse
  Home:   https://github.com/llvm/llvm-project
  Commit: 4653f93a9f1c30da3c900b2f68d43f456156c7c7
      https://github.com/llvm/llvm-project/commit/4653f93a9f1c30da3c900b2f68d43f456156c7c7
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
    M llvm/lib/Analysis/DependenceAnalysis.cpp
    M llvm/lib/Analysis/IVDescriptors.cpp
    M llvm/lib/Analysis/LoopCacheAnalysis.cpp
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
    M llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
    M llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
    M llvm/test/Transforms/IndVarSimplify/turn-to-invariant.ll
    M llvm/unittests/Analysis/ScalarEvolutionTest.cpp

  Log Message:
  -----------
  [SCEV] Introduce SCEVUse, use it instead of const SCEV * (NFCI) (WIP).

This patch introduces SCEVUse, which is a tagged pointer containing the
used const SCEV *, plus extra bits to store NUW/NSW flags that are only
valid at the specific use.

This was suggested by @nikic as an alternative
to https://github.com/llvm/llvm-project/pull/90742.

This patch just updates most SCEV infrastructure to operate on SCEVUse
instead of const SCEV *. It does not introduce any code that makes use
of the use-specific flags yet which I'll share as follow-ups.

Note that this should be NFC, but currently there's at least one case
where it is not (turn-to-invariant.ll), which I'll investigate once we
agree on the overall direction.

This PR at the moment also contains a commit that updates various SCEV
clients to use `const SCEV *` instead of `const auto *`, to prepare for
this patch. This reduces the number of changes needed, as SCEVUse will
automatically convert to `const SCEV *`. This is a safe default, as it
just drops the use-specific flags for the expression (it will not drop
any use-specific flags for any of its operands though).

This probably
SCEVUse could probably also be used to address mis-compiles due to
equivalent AddRecs modulo flags result in an AddRec with incorrect flags
for some uses of some phis, e.g. the one
https://github.com/llvm/llvm-project/pull/80430 attempted to fix

Compile-time impact:
stage1-O3: +0.06%
stage1-ReleaseThinLTO: +0.07%
stage1-ReleaseLTO-g: +0.07%
stage2-O3: +0.11%

https://llvm-compile-time-tracker.com/compare.php?from=ce055843e2be9643bd58764783a7bb69f6db8c9a&to=8c7f4e9e154ebc4862c4e2716cedc3c688352d7c&stat=instructions:u


  Commit: a8e9e7d01da3af0d2f2c7e68f0538dfac5d21a07
      https://github.com/llvm/llvm-project/commit/a8e9e7d01da3af0d2f2c7e68f0538dfac5d21a07
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/lib/Analysis/ScalarEvolution.cpp

  Log Message:
  -----------
  !fixup use raw pointer (const SCEV * + lower bits) for AddPointer.


  Commit: 23ccc88acb8157aa5600e5ef3d04a91222c6408c
      https://github.com/llvm/llvm-project/commit/23ccc88acb8157aa5600e5ef3d04a91222c6408c
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

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

  Log Message:
  -----------
  !fix formatting


  Commit: 89822e5db578305e2e5cc0ff4bdbebac981d7c25
      https://github.com/llvm/llvm-project/commit/89822e5db578305e2e5cc0ff4bdbebac981d7c25
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

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

  Log Message:
  -----------
  !fixup fix build failures after rebase, address comments


  Commit: 2dfaef3669260a3fc823cd4124063146716e45ed
      https://github.com/llvm/llvm-project/commit/2dfaef3669260a3fc823cd4124063146716e45ed
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/lib/Analysis/ScalarEvolution.cpp

  Log Message:
  -----------
  !fixup isCanonical/getCanonical


  Commit: a777a0e7805280dfb3aafe19dfbcab967c53e912
      https://github.com/llvm/llvm-project/commit/a777a0e7805280dfb3aafe19dfbcab967c53e912
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-10-09 (Wed, 09 Oct 2024)

  Changed paths:
    M polly/include/polly/Support/ScopHelper.h
    M polly/lib/Analysis/ScopBuilder.cpp
    M polly/lib/Analysis/ScopDetection.cpp
    M polly/lib/Analysis/ScopInfo.cpp
    M polly/lib/Support/SCEVAffinator.cpp
    M polly/lib/Support/SCEVValidator.cpp
    M polly/lib/Support/ScopHelper.cpp
    M polly/lib/Support/VirtualInstruction.cpp

  Log Message:
  -----------
  !fixup fix polly buildfailures


Compare: https://github.com/llvm/llvm-project/compare/45b5e628eace...a777a0e78052

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