[all-commits] [llvm/llvm-project] 6cdc22: [InstCombine] Fix bug in `FoldOpIntoSelect` where ...

goldsteinn via All-commits all-commits at lists.llvm.org
Mon May 1 15:24:14 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6cdc229a64be8dacba40d30a9032c14f51ee30c0
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-05-01 (Mon, 01 May 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/binop-select.ll

  Log Message:
  [InstCombine] Fix bug in `FoldOpIntoSelect` where we would incorrectly fold `undef` as constant

D146349 Introduced the ability to use the information from the
`select` condition to deduce constants as we folded a binop into
select. I.e if the `select` cond was `icmp eq %A, 10`, then in the
true-arm of `select`, we would be able to replace usage of `A` with

This is broken for vectors that contain `undef` elements. I.e with
`icmp eq %A, <10, undef>`, subsituting `<10, undef>` for `A` can
result in creating a more undefined result than we otherwise would

We fix the issue with simply checking if the candidate constant for
substituting may contain `undef` elements and don't do it in that

Reviewed By: nikic

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

  Commit: 6c667abf3294d61e4fbe1238e1755c79f7547f1b
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2023-05-01 (Mon, 01 May 2023)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/test/Transforms/LICM/speculate-div.ll

  Log Message:
  Recommit "[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate" (2nd Try)

Add `poison` checks that where missing.

Reviewed By: nikic

Compare: https://github.com/llvm/llvm-project/compare/819d1e860ea7...6c667abf3294

More information about the All-commits mailing list