This is an archive of the discontinued LLVM Phabricator instance.

[JumpThreading] Thread jumps through two basic blocks
AbandonedPublic

Authored by kazu on Jan 13 2020, 6:19 AM.

Details

Reviewers
wmi
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.

Event Timeline

kazu created this revision.Jan 13 2020, 6:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2020, 6:19 AM
Herald added subscribers: jfb, hiraditya. · View Herald Transcript
kazu abandoned this revision.Jan 15 2020, 7:27 AM

I'm abandoning this change. We'll discuss the revision in https://reviews.llvm.org/D70247 instead.