[PATCH] D72615: [JumpThreading] Thread jumps through two basic blocks

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 06:26:11 PST 2020


kazu created this revision.
kazu added a reviewer: wmi.
Herald added subscribers: jfb, hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72615

Files:
  llvm/include/llvm/Transforms/Scalar/JumpThreading.h
  llvm/lib/Transforms/Scalar/JumpThreading.cpp
  llvm/test/Transforms/JumpThreading/thread-two-bbs1.ll
  llvm/test/Transforms/JumpThreading/thread-two-bbs2.ll
  llvm/test/Transforms/JumpThreading/thread-two-bbs3.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72615.237657.patch
Type: text/x-patch
Size: 15360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/012f17fa/attachment.bin>


More information about the llvm-commits mailing list