[all-commits] [llvm/llvm-project] 9bad7d: [SimplifyCFG] Handle two equal cases in switch to ...

Nikita Popov via All-commits all-commits at lists.llvm.org
Sun Apr 4 08:32:29 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9bad7de9a3fb844f1ca2965f35d0c2a3d1e11775
      https://github.com/llvm/llvm-project/commit/9bad7de9a3fb844f1ca2965f35d0c2a3d1e11775
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-04-04 (Sun, 04 Apr 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/PhaseOrdering/partialord-ule.ll
    M llvm/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll

  Log Message:
  -----------
  [SimplifyCFG] Handle two equal cases in switch to select

When converting a switch with two cases and a default into a
select, also handle the denegerate case where two cases have the
same value.

Generate this case directly as

  %or = or i1 %cmp1, %cmp2
  %res = select i1 %or, i32 %val, i32 %default

rather than

  %sel1 = select i1 %cmp1, i32 %val, i32 %default
  %res = select i1 %cmp2, i32 %val, i32 %sel1

as InstCombine is going to canonicalize to the former anyway.




More information about the All-commits mailing list