[all-commits] [llvm/llvm-project] ac4006: [InstCombine] Don't slice up PHIs when pred BB has...

Heejin Ahn via All-commits all-commits at lists.llvm.org
Mon Jun 13 18:32:28 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ac4006b0d69ff3349fdd6c0bf8e4dad9504d438a
  Author: Heejin Ahn <aheejin at gmail.com>
  Date:   2022-06-13 (Mon, 13 Jun 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
    M llvm/test/Transforms/InstCombine/catchswitch-phi.ll

  Log Message:
  [InstCombine] Don't slice up PHIs when pred BB has catchswitch

If an integer PHI has an illegal type (according to the data layout) and
it is only used by `trunc` or `trunc(lshr)` operations, we split the PHI
into various instructions in its predecessors:

So this can produce code like the following:

  %p = phi i8 [ %somevalue, %pred ], ...
  %tobool = trunc i8 %p to i1
  use %tobool
In this code, `%p` has an illegal integer type, `i8`, and its only used
in a `trunc` instruction later. In this case this pass puts extraction
code in its predecessors:

  %t = and i8 %somevalue, 1
  %extract = icmp ne i8 %t, 0

  %p.new = phi i1 [ %extract, %pred ], ...
  use %p.new instead of %tobool

But this doesn't work if `pred` is a `catchswitch` BB because it cannot
have any non-PHI instructions. This CL ensures we bail out in that case.

Fixes https://github.com/llvm/llvm-project/issues/55803.

Reviewed By: dschuff

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

More information about the All-commits mailing list