-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ValueTracking] Use SimplifyQuery
in isKnownNonEqual
#124942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,18 +316,14 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2, | |
const SimplifyQuery &Q); | ||
|
||
bool llvm::isKnownNonEqual(const Value *V1, const Value *V2, | ||
const DataLayout &DL, AssumptionCache *AC, | ||
const Instruction *CxtI, const DominatorTree *DT, | ||
bool UseInstrInfo) { | ||
const SimplifyQuery &Q, unsigned Depth) { | ||
// We don't support looking through casts. | ||
if (V1 == V2 || V1->getType() != V2->getType()) | ||
return false; | ||
auto *FVTy = dyn_cast<FixedVectorType>(V1->getType()); | ||
APInt DemandedElts = | ||
FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); | ||
return ::isKnownNonEqual( | ||
V1, V2, DemandedElts, 0, | ||
SimplifyQuery(DL, DT, AC, safeCxtI(V2, V1, CxtI), UseInstrInfo)); | ||
return ::isKnownNonEqual(V1, V2, DemandedElts, Depth, Q); | ||
Comment on lines
-328
to
+326
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add the Depth argument? Is the plan to support depth > 0 in follow-ups? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be set to |
||
} | ||
|
||
bool llvm::MaskedValueIsZero(const Value *V, const APInt &Mask, | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1609,17 +1609,13 @@ if.else: | |||||||||||||||||||||||
ret i16 0 | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
; TODO: %cmp always evaluates to false | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
define i1 @test_simplify_icmp2(double %x) { | ||||||||||||||||||||||||
; CHECK-LABEL: @test_simplify_icmp2( | ||||||||||||||||||||||||
; CHECK-NEXT: [[ABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]]) | ||||||||||||||||||||||||
; CHECK-NEXT: [[COND:%.*]] = fcmp oeq double [[ABS]], 0x7FF0000000000000 | ||||||||||||||||||||||||
; CHECK-NEXT: br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] | ||||||||||||||||||||||||
; CHECK: if.then: | ||||||||||||||||||||||||
; CHECK-NEXT: [[CAST:%.*]] = bitcast double [[X]] to i64 | ||||||||||||||||||||||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[CAST]], 3458764513820540928 | ||||||||||||||||||||||||
; CHECK-NEXT: ret i1 [[CMP]] | ||||||||||||||||||||||||
; CHECK-NEXT: ret i1 false | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand why this change isn't NFC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With DC we will have a more precise KnownBits: llvm-project/llvm/lib/Analysis/ValueTracking.cpp Lines 3830 to 3840 in 8af24ce
|
||||||||||||||||||||||||
; CHECK: if.else: | ||||||||||||||||||||||||
; CHECK-NEXT: ret i1 false | ||||||||||||||||||||||||
; | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually using a null context instruction intentionally, to avoid order-dependence. But due to the implicit context, it ended up not mattering, and now things rely on it... It's okay for now, keeping symmetry in this code is not super important.