[all-commits] [llvm/llvm-project] 5207cd: [InstCombine] Conditionally fold select i1 into an...

Juneyoung Lee via All-commits all-commits at lists.llvm.org
Sat Apr 3 22:16:15 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5207cde5cb4147155c469e1861427ea9d569bd5a
      https://github.com/llvm/llvm-project/commit/5207cde5cb4147155c469e1861427ea9d569bd5a
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2021-04-04 (Sun, 04 Apr 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/test/Transforms/InstCombine/and-fcmp.ll
    M llvm/test/Transforms/InstCombine/onehot_merge.ll
    M llvm/test/Transforms/InstCombine/pr49688.ll
    M llvm/test/Transforms/InstCombine/signed-truncation-check.ll
    M llvm/test/Transforms/InstCombine/widenable-conditions.ll

  Log Message:
  -----------
  [InstCombine] Conditionally fold select i1 into and/or

This patch fixes llvm.org/pr49688 by conditionally folding select i1 into and/or:

```
select cond, cond2, false
->
and cond, cond2
```

This is not safe if cond2 is poison whereas cond isn’t.

Unconditionally disabling this transformation affects later pipelines that depend on and/or i1s.
To minimize its impact, this patch conservatively checks whether cond2 is an instruction that
creates a poison or its operand creates a poison.
This approach is similar to what InstSimplify's SimplifyWithOpReplaced is doing.

Reviewed By: nikic

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




More information about the All-commits mailing list