[all-commits] [llvm/llvm-project] 23d591: [NFC][LSR] Add test case that from https://reviews...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Mar 13 05:06:12 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 23d591efae68604a8620cbb1a7755eee0279290e
      https://github.com/llvm/llvm-project/commit/23d591efae68604a8620cbb1a7755eee0279290e
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-13 (Sat, 13 Mar 2021)

  Changed paths:
    A llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll

  Log Message:
  -----------
  [NFC][LSR] Add test case that from https://reviews.llvm.org/D98147#2623549

With that patch, this test fails with an assertion
```
opt: /repositories/llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5169: BasicBlock::iterator (anonymous namespace)::LSRInstance::AdjustInsertPositionForExpand(BasicBlock::iterator, const (anonymous namespace)::LSRFixup &, const (anonymous namespace)::LSRUse &, llvm::SCEVExpander &) const: Assertion `!isa<PHINode>(LowestIP) && !LowestIP->isEHPad() && !isa<DbgInfoIntrinsic>(LowestIP) && "Insertion point must be a normal instruction"' failed.
```


  Commit: 6e9b9978cfb71b3c5de315dbc628e5909baa71da
      https://github.com/llvm/llvm-project/commit/6e9b9978cfb71b3c5de315dbc628e5909baa71da
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-13 (Sat, 13 Mar 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    A llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point-2.ll

  Log Message:
  -----------
  [LSR] Don't try to fixup uses in 'EH pad' instructions

The added test case crashes before this fix:
```
opt: /repositories/llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5172: BasicBlock::iterator (anonymous namespace)::LSRInstance::AdjustInsertPositionForExpand(BasicBlock::iterator, const (anonymous namespace)::LSRFixup &, const (anonymous namespace)::LSRUse &, llvm::SCEVExpander &) const: Assertion `!isa<PHINode>(LowestIP) && !LowestIP->isEHPad() && !isa<DbgInfoIntrinsic>(LowestIP) && "Insertion point must be a normal instruction"' failed.
```
This is fully analogous to the previous commit,
with the pointer constant replaced to be something non-null.

The comparison here can be strength-reduced,
but the second operand of the comparison happens to be identical
to the constant pointer in the `catch` case of `landingpad`.

While LSRInstance::CollectLoopInvariantFixupsAndFormulae()
already gave up on uses in blocks ending up with EH pads,
it didn't consider this case.

Eventually, `LSRInstance::AdjustInsertPositionForExpand()`
will be called, but the original insertion point it will get
is the user instruction itself, and it doesn't want to
deal with EH pads, and asserts as much.

It would seem that this basically never happens in-the-wild,
otherwise it would have been reported already,
so it seems safe to take the cautious approach,
and just not deal with such users.


  Commit: 78b8ce40efeb578534543fcb948cb9db22e5b81f
      https://github.com/llvm/llvm-project/commit/78b8ce40efeb578534543fcb948cb9db22e5b81f
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-03-13 (Sat, 13 Mar 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/load.ll
    M llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll
    M llvm/test/Analysis/ScalarEvolution/scalable-vector.ll
    M llvm/test/CodeGen/AMDGPU/splitkit-getsubrangeformask.ll
    M llvm/test/CodeGen/PowerPC/pr43527.ll
    M llvm/test/CodeGen/PowerPC/pr48519.ll
    M llvm/test/CodeGen/PowerPC/sms-phi.ll
    M llvm/test/Other/constant-fold-gep.ll
    M llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll
    M llvm/test/Transforms/IndVarSimplify/widen-i32-i8ptr.ll
    M llvm/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
    M llvm/test/Transforms/LoopStrengthReduce/AMDGPU/lsr-postinc-pos-addrspace.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/eh-insertion-point.ll
    M llvm/test/Transforms/LoopVectorize/X86/cost-model-assert.ll
    M llvm/test/Transforms/LoopVectorize/pointer-induction.ll
    M llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
    M polly/lib/Analysis/ScopBuilder.cpp
    M polly/lib/Support/SCEVAffinator.cpp
    M polly/lib/Support/SCEVValidator.cpp
    M polly/test/Isl/CodeGen/partial_write_impossible_restriction.ll
    M polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll

  Log Message:
  -----------
  Reland [SCEV] Improve modelling for (null) pointer constants

This reverts commit 329aeb5db43f5e69df038fb20d2def77fe6f8595,
and relands commit 61f006ac655431bd44b9e089f74c73bec0c1a48c.

This is a continuation of D89456.

As it was suggested there, now that SCEV models `PtrToInt`,
we can try to improve SCEV's pointer handling.
In particular, i believe, i will need this in the future
to further fix `SCEVAddExpr`operation type handling.

This removes special handling of `ConstantPointerNull`
from `ScalarEvolution::createSCEV()`, and add constant folding
into `ScalarEvolution::getPtrToIntExpr()`.
This way, `null` constants stay as such in SCEV's,
but gracefully become zero integers when asked.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D98147


Compare: https://github.com/llvm/llvm-project/compare/2468fdd9af36...78b8ce40efeb


More information about the All-commits mailing list