[PATCH] D84629: [LazyValueInfo] Let getEdgeValueLocal look into freeze instructions
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 18:16:17 PDT 2020
aqjune updated this revision to Diff 284541.
aqjune added a comment.
Remove redundant check
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84629/new/
https://reviews.llvm.org/D84629
Files:
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/test/Transforms/JumpThreading/freeze-lvi-edgevaluelocal.ll
Index: llvm/test/Transforms/JumpThreading/freeze-lvi-edgevaluelocal.ll
===================================================================
--- llvm/test/Transforms/JumpThreading/freeze-lvi-edgevaluelocal.ll
+++ llvm/test/Transforms/JumpThreading/freeze-lvi-edgevaluelocal.ll
@@ -9,10 +9,7 @@
define i32 @simple(i1 %cond) {
; CHECK-LABEL: @simple(
; CHECK-NEXT: ENTRY:
-; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 [[COND:%.*]]
-; CHECK-NEXT: br i1 [[COND]], label [[A:%.*]], label [[EXIT:%.*]]
-; CHECK: A:
-; CHECK-NEXT: br i1 [[COND_FR]], label [[B:%.*]], label [[EXIT]]
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[B:%.*]], label [[EXIT:%.*]]
; CHECK: B:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret i32 1
@@ -36,8 +33,8 @@
; CHECK-NEXT: ENTRY:
; CHECK-NEXT: [[COND_FR:%.*]] = freeze i32 [[COND:%.*]]
; CHECK-NEXT: switch i32 [[COND]], label [[DEFAULT:%.*]] [
-; CHECK-NEXT: i32 0, label [[A:%.*]]
-; CHECK-NEXT: i32 1, label [[B:%.*]]
+; CHECK-NEXT: i32 0, label [[A_TAKEN:%.*]]
+; CHECK-NEXT: i32 1, label [[B_TAKEN:%.*]]
; CHECK-NEXT: ]
; CHECK: DEFAULT:
; CHECK-NEXT: switch i32 [[COND_FR]], label [[PRESERVED1:%.*]] [
@@ -49,26 +46,12 @@
; CHECK: PRESERVED2:
; CHECK-NEXT: call void @f2()
; CHECK-NEXT: ret void
-; CHECK: A:
-; CHECK-NEXT: switch i32 [[COND_FR]], label [[A_NOTTAKEN:%.*]] [
-; CHECK-NEXT: i32 0, label [[A_TAKEN:%.*]]
-; CHECK-NEXT: ]
; CHECK: A_TAKEN:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
-; CHECK: A_NOTTAKEN:
-; CHECK-NEXT: call void @f2()
-; CHECK-NEXT: ret void
-; CHECK: B:
-; CHECK-NEXT: switch i32 [[COND_FR]], label [[B_TAKEN:%.*]] [
-; CHECK-NEXT: i32 0, label [[B_NOTTAKEN:%.*]]
-; CHECK-NEXT: ]
; CHECK: B_TAKEN:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
-; CHECK: B_NOTTAKEN:
-; CHECK-NEXT: call void @f2()
-; CHECK-NEXT: ret void
;
ENTRY:
%cond.fr = freeze i32 %cond
Index: llvm/lib/Analysis/LazyValueInfo.cpp
===================================================================
--- llvm/lib/Analysis/LazyValueInfo.cpp
+++ llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1221,11 +1221,11 @@
}
// Return true if the instruction type of Val is supported by
-// constantFoldUser(). Currently CastInst and BinaryOperator only. Call this
-// before calling constantFoldUser() to find out if it's even worth attempting
-// to call it.
+// constantFoldUser(). Currently CastInst, BinaryOperator and FreezeInst only.
+// Call this before calling constantFoldUser() to find out if it's even worth
+// attempting to call it.
static bool isOperationFoldable(User *Usr) {
- return isa<CastInst>(Usr) || isa<BinaryOperator>(Usr);
+ return isa<CastInst>(Usr) || isa<BinaryOperator>(Usr) || isa<FreezeInst>(Usr);
}
// Check if Usr can be simplified to an integer constant when the value of one
@@ -1256,6 +1256,9 @@
SimplifyBinOp(BO->getOpcode(), LHS, RHS, DL))) {
return ValueLatticeElement::getRange(ConstantRange(C->getValue()));
}
+ } else if (auto *FI = dyn_cast<FreezeInst>(Usr)) {
+ assert(FI->getOperand(0) == Op && "Operand 0 isn't Op");
+ return ValueLatticeElement::getRange(ConstantRange(OpConstVal));
}
return ValueLatticeElement::getOverdefined();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84629.284541.patch
Type: text/x-patch
Size: 3330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/232d0672/attachment.bin>
More information about the llvm-commits
mailing list