[all-commits] [llvm/llvm-project] 53b68e: Resubmit: [JumpThreading] Thread jumps through two...

kazutakahirata via All-commits all-commits at lists.llvm.org
Thu Jan 16 12:34:00 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 53b68e676faf208b4a8f817e9bd4ddd522cc6006
      https://github.com/llvm/llvm-project/commit/53b68e676faf208b4a8f817e9bd4ddd522cc6006
  Author: Kazu Hirata <kazu at google.com>
  Date:   2020-01-16 (Thu, 16 Jan 2020)

  Changed paths:
    M llvm/include/llvm/Transforms/Scalar/JumpThreading.h
    M llvm/lib/Transforms/Scalar/JumpThreading.cpp
    A llvm/test/Transforms/JumpThreading/thread-two-bbs1.ll
    A llvm/test/Transforms/JumpThreading/thread-two-bbs2.ll
    A llvm/test/Transforms/JumpThreading/thread-two-bbs3.ll

  Log Message:
  -----------
  Resubmit: [JumpThreading] Thread jumps through two basic blocks

This reverts commit 2d258ed931cdf47a7d1dcf08ad963b5452a8670f.  This
revision fixes the Windows build and adds a testcase for it, namely
thread-two-bbs3.ll.  My original patch improperly copied EH pads on
Windows.  This patch disregards jump threading opportunities having to
do with EH pads.

[JumpThreading] Thread jumps through two basic blocks

Summary:
This patch teaches JumpThreading.cpp to thread through two basic
blocks like:

  bb3:
    %var = phi i32* [ null, %bb1 ], [ @a, %bb2 ]
    %tobool = icmp eq i32 %cond, 0
    br i1 %tobool, label %bb4, label ...

  bb4:
    %cmp = icmp eq i32* %var, null
    br i1 %cmp, label bb5, label bb6

by duplicating basic blocks like bb3 above.  Once we duplicate bb3 as
bb3.dup and redirect edge bb2->bb3 to bb2->bb3.dup, we have:

  bb3:
    %var = phi i32* [ @a, %bb2 ]
    %tobool = icmp eq i32 %cond, 0
    br i1 %tobool, label %bb4, label ...

  bb3.dup:
    %var = phi i32* [ null, %bb1 ]
    %tobool = icmp eq i32 %cond, 0
    br i1 %tobool, label %bb4, label ...

  bb4:
    %cmp = icmp eq i32* %var, null
    br i1 %cmp, label bb5, label bb6

Then the existing code in JumpThreading.cpp can thread edge
bb3.dup->bb4 through bb4 and eventually create bb3.dup->bb5.

Reviewers: wmi

Subscribers: hiraditya, jfb, llvm-commits

Tags: #llvm

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




More information about the All-commits mailing list