[all-commits] [llvm/llvm-project] 12d93a: [InstCombine] Sanitize undef vector constant to 1 ...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Wed Aug 12 12:07:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 12d93a27e7b78d58dd00817cb737f273d2dba8ae
      https://github.com/llvm/llvm-project/commit/12d93a27e7b78d58dd00817cb737f273d2dba8ae
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-08-12 (Wed, 12 Aug 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/getelementptr.ll
    M llvm/test/Transforms/InstCombine/mul.ll

  Log Message:
  -----------
  [InstCombine] Sanitize undef vector constant to 1 in  X*(2^C) with X << C (PR47133)

While x*undef is undef, shift-by-undef is poison,
which we must avoid introducing.

Also log2(iN undef) is *NOT* iN undef, because log2(iN undef) u< N.

See https://bugs.llvm.org/show_bug.cgi?id=47133


  Commit: d6f0600c96a6b05ccfe378c9ab9dc0d426f92bd4
      https://github.com/llvm/llvm-project/commit/d6f0600c96a6b05ccfe378c9ab9dc0d426f92bd4
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-08-12 (Wed, 12 Aug 2020)

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

  Log Message:
  -----------
  [NFC][InstCombine] Add FIXME's for getLogBase2() / visitUDivOperand()

These are not correctness issues.

In visitUDivOperand(), if the (potential) divisor is undef, then udiv is
already UB, so it is not incorrect to keep undef as shift amount.

But, that is suboptimal.
We could instead simply drop that select, picking the other operand.

Afterwards, getLogBase2() could assert that there is no undef in divisor.


Compare: https://github.com/llvm/llvm-project/compare/c561f4d2ec19...d6f0600c96a6


More information about the All-commits mailing list