[llvm] e734e82 - [JumpThreading] Remove cast's constraint
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 03:09:44 PDT 2020
Author: Juneyoung Lee
Date: 2020-08-04T19:09:25+09:00
New Revision: e734e8286b4b521d829aaddb6d1cbbd264953625
URL: https://github.com/llvm/llvm-project/commit/e734e8286b4b521d829aaddb6d1cbbd264953625
DIFF: https://github.com/llvm/llvm-project/commit/e734e8286b4b521d829aaddb6d1cbbd264953625.diff
LOG: [JumpThreading] Remove cast's constraint
As discussed in D84949, this removes the constraint to cast since it does not
cause compile time degradation.
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D85188
Added:
Modified:
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/threadable-edge-cast.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index f42d4841f7939..e6d261fa9aff5 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -674,13 +674,9 @@ bool JumpThreadingPass::ComputeValueKnownInPredecessorsImpl(
return !Result.empty();
}
- // Handle Cast instructions. Only see through Cast when the source operand is
- // PHI, Cmp, or Freeze to save the compilation time.
+ // Handle Cast instructions.
if (CastInst *CI = dyn_cast<CastInst>(I)) {
Value *Source = CI->getOperand(0);
- if (!isa<PHINode>(Source) && !isa<CmpInst>(Source) &&
- !isa<FreezeInst>(Source))
- return false;
ComputeValueKnownInPredecessorsImpl(Source, BB, Result, Preference,
RecursionSet, CxtI);
if (Result.empty())
diff --git a/llvm/test/Transforms/JumpThreading/threadable-edge-cast.ll b/llvm/test/Transforms/JumpThreading/threadable-edge-cast.ll
index 71c34dea3a069..ef1e8f28d14f1 100644
--- a/llvm/test/Transforms/JumpThreading/threadable-edge-cast.ll
+++ b/llvm/test/Transforms/JumpThreading/threadable-edge-cast.ll
@@ -11,20 +11,14 @@ define i32 @test(i1 %cond0) {
; CHECK-NEXT: br i1 [[COND0:%.*]], label [[T1:%.*]], label [[F1:%.*]]
; CHECK: T1:
; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
-; CHECK-NEXT: br label [[MERGE:%.*]]
+; CHECK-NEXT: br label [[F2:%.*]]
; CHECK: F1:
; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
-; CHECK-NEXT: br label [[MERGE]]
-; CHECK: Merge:
+; CHECK-NEXT: br label [[F2]]
+; CHECK: F2:
; CHECK-NEXT: [[A:%.*]] = phi i32 [ 10, [[T1]] ], [ 0, [[F1]] ]
; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[V1]], [[T1]] ], [ [[V2]], [[F1]] ]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[A]], 1
-; CHECK-NEXT: [[COND:%.*]] = trunc i32 [[AND]] to i1
-; CHECK-NEXT: br i1 [[COND]], label [[T2:%.*]], label [[F2:%.*]]
-; CHECK: T2:
-; CHECK-NEXT: call void @f3()
-; CHECK-NEXT: ret i32 [[B]]
-; CHECK: F2:
; CHECK-NEXT: ret i32 [[B]]
;
br i1 %cond0, label %T1, label %F1
@@ -57,21 +51,15 @@ define i32 @test2(i1 %cond0) {
; CHECK-NEXT: br i1 [[COND0:%.*]], label [[T1:%.*]], label [[F1:%.*]]
; CHECK: T1:
; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
-; CHECK-NEXT: br label [[MERGE:%.*]]
+; CHECK-NEXT: br label [[F2:%.*]]
; CHECK: F1:
; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
-; CHECK-NEXT: br label [[MERGE]]
-; CHECK: Merge:
+; CHECK-NEXT: br label [[F2]]
+; CHECK: F2:
; CHECK-NEXT: [[A:%.*]] = phi i1 [ true, [[T1]] ], [ false, [[F1]] ]
; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[V1]], [[T1]] ], [ [[V2]], [[F1]] ]
; CHECK-NEXT: [[A2:%.*]] = xor i1 [[A]], true
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[A2]], i32 10, i32 0
-; CHECK-NEXT: [[COND:%.*]] = trunc i32 [[SEL]] to i1
-; CHECK-NEXT: br i1 [[COND]], label [[T2:%.*]], label [[F2:%.*]]
-; CHECK: T2:
-; CHECK-NEXT: call void @f3()
-; CHECK-NEXT: ret i32 [[B]]
-; CHECK: F2:
; CHECK-NEXT: ret i32 [[B]]
;
br i1 %cond0, label %T1, label %F1
More information about the llvm-commits
mailing list