[all-commits] [llvm/llvm-project] 335528: [NFC][SCEVExpander] isHighCostExpansionHelper(): r...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Mon Oct 19 14:11:23 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3355284b2d7652cd2f7ae01aa0323ea3f963641b
      https://github.com/llvm/llvm-project/commit/3355284b2d7652cd2f7ae01aa0323ea3f963641b
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

  Log Message:
  -----------
  [NFC][SCEVExpander] isHighCostExpansionHelper(): rewrite as a switch

If we switch over an enum, compiler can easily issue a diagnostic
if some case is not handled. However with an if cascade that isn't so.
Experimental evidence suggests new behavior to be superior.


  Commit: d4b0aa9773a98f5072384bda414e70f6df335237
      https://github.com/llvm/llvm-project/commit/d4b0aa9773a98f5072384bda414e70f6df335237
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

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

  Log Message:
  -----------
  [NFC][SCEV] BuildConstantFromSCEV(): reformat, NFC

Makes diff in next commit more readable


  Commit: e0567582b8b1def8656f4a5addce0909fa51c86e
      https://github.com/llvm/llvm-project/commit/e0567582b8b1def8656f4a5addce0909fa51c86e
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

  Log Message:
  -----------
  [NFCI][SCEV] Always refer to enum SCEVTypes as enum, not integer

The main tricky thing here is forward-declaring the enum:
we have to specify it's underlying data type.

In particular, this avoids the danger of switching over the SCEVTypes,
but actually switching over an integer, and not being notified
when some case is not handled.

I have updated most of such switches to be exaustive and not have
a default case, where it's pretty obvious to be the intent,
however not all of them.


Compare: https://github.com/llvm/llvm-project/compare/d605a119939a...e0567582b8b1


More information about the All-commits mailing list