[PATCH] D85023: [JumpThreading] Consider freeze as a zero-cost instruction
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 01:23:03 PDT 2020
aqjune updated this revision to Diff 282822.
aqjune added a comment.
Update test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85023/new/
https://reviews.llvm.org/D85023
Files:
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/thread-two-bbs-threshold.ll
Index: llvm/test/Transforms/JumpThreading/thread-two-bbs-threshold.ll
===================================================================
--- llvm/test/Transforms/JumpThreading/thread-two-bbs-threshold.ll
+++ llvm/test/Transforms/JumpThreading/thread-two-bbs-threshold.ll
@@ -10,26 +10,26 @@
; CHECK-LABEL: @foo(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[COND1:%.*]], 0
-; CHECK-NEXT: br i1 [[TOBOOL]], label [[BB_COND2:%.*]], label [[BB_F1:%.*]]
-; CHECK: bb.f1:
-; CHECK-NEXT: call void @f1()
-; CHECK-NEXT: br label [[BB_COND2]]
+; CHECK-NEXT: br i1 [[TOBOOL]], label [[BB_COND2_THREAD:%.*]], label [[BB_COND2:%.*]]
; CHECK: bb.cond2:
-; CHECK-NEXT: [[PTR:%.*]] = phi i32* [ null, [[BB_F1]] ], [ @a, [[ENTRY:%.*]] ]
+; CHECK-NEXT: call void @f1()
; CHECK-NEXT: [[COND2_FR:%.*]] = freeze i32 [[COND2:%.*]]
; CHECK-NEXT: [[X:%.*]] = add i32 [[COND2_FR]], 1
; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[X]], 0
-; CHECK-NEXT: br i1 [[TOBOOL1]], label [[BB_FILE:%.*]], label [[BB_F2:%.*]]
+; CHECK-NEXT: br i1 [[TOBOOL1]], label [[BB_F4:%.*]], label [[BB_F2:%.*]]
+; CHECK: bb.cond2.thread:
+; CHECK-NEXT: [[COND2_FR2:%.*]] = freeze i32 [[COND2]]
+; CHECK-NEXT: [[X3:%.*]] = add i32 [[COND2_FR2]], 1
+; CHECK-NEXT: [[TOBOOL14:%.*]] = icmp eq i32 [[X3]], 0
+; CHECK-NEXT: br i1 [[TOBOOL14]], label [[BB_F3:%.*]], label [[BB_F2]]
; CHECK: bb.f2:
; CHECK-NEXT: call void @f2()
; CHECK-NEXT: br label [[EXIT:%.*]]
-; CHECK: bb.file:
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[PTR]], null
-; CHECK-NEXT: br i1 [[CMP]], label [[BB_F4:%.*]], label [[BB_F3:%.*]]
; CHECK: bb.f3:
; CHECK-NEXT: call void @f3()
; CHECK-NEXT: br label [[EXIT]]
; CHECK: bb.f4:
+; CHECK-NEXT: [[PTR5:%.*]] = phi i32* [ null, [[BB_COND2]] ]
; CHECK-NEXT: call void @f4()
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
Index: llvm/lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -535,6 +535,10 @@
if (isa<BitCastInst>(I) && I->getType()->isPointerTy())
continue;
+ // Freeze instruction is free, too.
+ if (isa<FreezeInst>(I))
+ continue;
+
// Bail out if this instruction gives back a token type, it is not possible
// to duplicate it if it is used outside this BB.
if (I->getType()->isTokenTy() && I->isUsedOutsideOfBlock(BB))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85023.282822.patch
Type: text/x-patch
Size: 2564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200804/d4da386a/attachment.bin>
More information about the llvm-commits
mailing list