[all-commits] [llvm/llvm-project] 2b8514: [NFC][InstCombine] Negator: do not include unneede...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Wed Jun 17 12:48:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b851473372164f4487340434d12fbc722ba3e71
      https://github.com/llvm/llvm-project/commit/2b851473372164f4487340434d12fbc722ba3e71
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-17 (Wed, 17 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp

  Log Message:
  -----------
  [NFC][InstCombine] Negator: do not include unneeded "llvm/IR/DerivedTypes.h" header


  Commit: c4166f3d84985a8eddfc12dce10a2f66f7dc98d6
      https://github.com/llvm/llvm-project/commit/c4166f3d84985a8eddfc12dce10a2f66f7dc98d6
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-17 (Wed, 17 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp

  Log Message:
  -----------
  [NFC][InstCombine] Negator: add thin negate() wrapped before visit()


  Commit: e3d8cb1e1d227c61576914e42435b5e71d442631
      https://github.com/llvm/llvm-project/commit/e3d8cb1e1d227c61576914e42435b5e71d442631
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-17 (Wed, 17 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
    M llvm/test/Transforms/InstCombine/sub-of-negatible.ll

  Log Message:
  -----------
  [InstCombine] Negator: cache negation results (PR46362)

It is possible that we can try to negate the same value multiple times.
For example, PHI nodes may happen to have multiple incoming values
(all of which must be the same value) for the same incoming basic block.
It may happen that we try to negate such a PHI node, and succeed,
and that might result in having now-different incoming values..

To avoid that, and in general to reduce the amount of duplicated
work we might be doing, let's introduce a cache where
we'll track results of negating each value.

The added test was previously failing -verify after -instcombine.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46362


  Commit: 84b4f5a6a6bc834c325edef7baec335b81b6e367
      https://github.com/llvm/llvm-project/commit/84b4f5a6a6bc834c325edef7baec335b81b6e367
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-17 (Wed, 17 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp

  Log Message:
  -----------
  [InstCombine] Negator: while there, add detection for cycles during negation

I don't have any testcases showing it happening,
and i haven't succeeded in creating one,
but i'm also not positive it can't ever happen,
and i recall having something that looked like
that in the very beginning of Negator creation.

But since we now already have a negation cache,
we can now detect such cases practically for free.

Let's do so instead of "relying" on stack overflow :D


Compare: https://github.com/llvm/llvm-project/compare/49754dcf2212...84b4f5a6a6bc


More information about the All-commits mailing list