[all-commits] [llvm/llvm-project] 747242: [InstCombine] allow more narrowing of casted select

RotateRight via All-commits all-commits at lists.llvm.org
Mon Jan 27 13:49:49 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 747242af8dd03916ab46a16c1e38e716550cb60b
      https://github.com/llvm/llvm-project/commit/747242af8dd03916ab46a16c1e38e716550cb60b
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2020-01-27 (Mon, 27 Jan 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/test/Transforms/InstCombine/cast-select.ll
    M llvm/test/Transforms/InstCombine/select-imm-canon.ll
    M llvm/test/Transforms/InstCombine/trunc.ll

  Log Message:
  -----------
  [InstCombine] allow more narrowing of casted select

D47163 created a rule that we should not change the casted
type of a select when we have matching types in its compare condition.
That was intended to help vector codegen, but it also could create
situations where we miss subsequent folds as shown in PR44545:
https://bugs.llvm.org/show_bug.cgi?id=44545

By using shouldChangeType(), we can continue to get the vector folds
(because we always return false for vector types). But we also solve
the motivating bug because it's ok to narrow the scalar select in that
example.

Our canonicalization rules around select are a mess, but AFAICT, this
will not induce any infinite looping from the reverse transform (but
we'll need to watch for that possibility if committed).

Side note: there's a similar use of shouldChangeType() for phi ops
just below this diff, and the source and destination types appear to
be reversed.

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




More information about the All-commits mailing list