[all-commits] [llvm/llvm-project] 7c87d7: test: Don't depend on behavior of switch lower in ...

Ruiling, Song via All-commits all-commits at lists.llvm.org
Wed Apr 13 22:31:41 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c87d75d74f3c2943b286b239ec6ff96fc5109c7
  Author: Ruiling Song <ruiling.song at amd.com>
  Date:   2022-04-14 (Thu, 14 Apr 2022)

  Changed paths:
    M llvm/test/CodeGen/AMDGPU/ipra-return-address-save-restore.ll

  Log Message:
  test: Don't depend on behavior of switch lower in one test. NFC

This is a preliminary change to update the test so that it does not
depend on how switch-case will be lowered. The following change will
lower switch-case more optimally that will make the test no longer

Reviewed by: arsenm

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

  Commit: 1e01f95057a702658a88879223586fde0122f038
  Author: Ruiling Song <ruiling.song at amd.com>
  Date:   2022-04-14 (Thu, 14 Apr 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/LowerSwitch.cpp
    M llvm/test/CodeGen/AMDGPU/multilevel-break.ll
    M llvm/test/Transforms/FixIrreducible/switch.ll
    M llvm/test/Transforms/LowerSwitch/2014-06-23-PHIlowering.ll
    M llvm/test/Transforms/LowerSwitch/do-not-handle-impossible-values.ll
    M llvm/test/Transforms/LowerSwitch/feature.ll
    M llvm/test/Transforms/StructurizeCFG/interleaved-loop-order.ll
    M llvm/test/Transforms/UnifyLoopExits/switch.ll
    M llvm/test/Transforms/Util/lowerswitch.ll

  Log Message:
  LowerSwitch: Avoid inserting NewDefault block

The NewDefault was used to simplify the updating of PHI nodes, but it
causes some inefficiency for target that will run structurizer later. For
example, for a simple two-case switch, the extra NewDefault is causing
unstructured CFG like:

       / \
      O   O
     / \ / \
    C1  ND C2
     \  |  /
      \ | /

The change is to avoid the ND(NewDefault) block, that is we will get a
structured CFG for above example like:

       / \
      /   \
     O     O
    / \   / \
   C1  \ /  C2
    \-> D <-/

The IR change introduced by this patch should be trivial to other targets,
so I am doing this unconditionally.

Fall-through among the cases will also cause unstructured CFG, but it need
more work and will be addressed in a separate change.

Reviewed by: arsenm

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

Compare: https://github.com/llvm/llvm-project/compare/bfafa105aab0...1e01f95057a7

More information about the All-commits mailing list