[all-commits] [llvm/llvm-project] 012f01: Precommit tests for D101720 (NFC)

Juneyoung Lee via All-commits all-commits at lists.llvm.org
Mon May 3 17:43:45 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 012f01e227eeb071dbce270aa36745fd6ca95af5
      https://github.com/llvm/llvm-project/commit/012f01e227eeb071dbce270aa36745fd6ca95af5
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2021-05-04 (Tue, 04 May 2021)

  Changed paths:
    A llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll

  Log Message:
  -----------
  Precommit tests for D101720 (NFC)


  Commit: 24ce194cfe493bb743c288ed049fcd86c37aace2
      https://github.com/llvm/llvm-project/commit/24ce194cfe493bb743c288ed049fcd86c37aace2
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2021-05-04 (Tue, 04 May 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/test/Transforms/InstCombine/select-safe-bool-transforms.ll
    M llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll

  Log Message:
  -----------
  [InstCombine] generalize select + select/and/or folding using implied conditions

This patch optimizes the remaining possible cases in D101191 by generalizing isImpliedCondition()-based
foldings.

Assume that there is `op a, (select b, _, _)` where op is one of `and i1`, `or i1` or their select forms.

We can do the following optimization based on the result of `isImpliedCondition(a, b)`:

If a = true implies…
- b = true:
    - select a, (select b, A, B), false => select a, A, false : https://alive2.llvm.org/ce/z/WCnZYh
    - and a, (select b, A, B) => select a, A, false : https://alive2.llvm.org/ce/z/uZhcMG
- b = false:
    - select a, (select b, A, B), false => select a, B, false : https://alive2.llvm.org/ce/z/c2hJpV
    - and a, (select b, A, B) => select a, B, false : https://alive2.llvm.org/ce/z/5ggwMM

If a = false implies…
- b = true:
    - select a, true, (select b, A, B) => select a, true, A : https://alive2.llvm.org/ce/z/tidKvH
    - or a, (select b, A, B) =>  select a, true, A : https://alive2.llvm.org/ce/z/cC-uyb
- b = false:
    - select a, true, (select b, A, B) => select a, true, B : https://alive2.llvm.org/ce/z/ZXpJq9
    - or a, (select b, A, B) => select a, true, B : https://alive2.llvm.org/ce/z/hnDrJj

Reviewed By: nikic

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


Compare: https://github.com/llvm/llvm-project/compare/60ad0fd3c8bf...24ce194cfe49


More information about the All-commits mailing list