[all-commits] [llvm/llvm-project] 4e545b: [SimplifyCFG] Thread branches on same condition in...

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri Apr 29 00:44:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4e545bdb355a470d601e9bb7f7b2693c99e61a3e
      https://github.com/llvm/llvm-project/commit/4e545bdb355a470d601e9bb7f7b2693c99e61a3e
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-04-29 (Fri, 29 Apr 2022)

  Changed paths:
    M clang/test/CodeGenObjC/exceptions.m
    M clang/test/CodeGenObjCXX/exceptions-legacy.mm
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/CodeGen/AArch64/arm64-andCmpBrToTBZ.ll
    M llvm/test/Transforms/GVNSink/sink-common-code.ll
    M llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll
    M llvm/test/Transforms/SimplifyCFG/jump-threading.ll
    M llvm/test/Transforms/SimplifyCFG/wc-widen-block.ll

  Log Message:
  -----------
  [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

SimplifyCFG implements basic jump threading, if a branch is
performed on a phi node with constant operands. However,
InstCombine canonicalizes such phis to the condition value of a
previous branch, if possible. SimplifyCFG does support this as
well, but only in the very limited case where the same condition
is used in a direct predecessor -- notably, this does not include
the common diamond pattern (i.e. two consecutive if/elses on the
same condition).

This patch extends the code to look back a limited number of
blocks to find a branch on the same value, rather than only
looking at the direct predecessor.

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

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




More information about the All-commits mailing list