-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Check FPMathOperator for Ctx before FMF check
We need to check FPMathOperator for Ctx instruction before checking fast math flag on this Ctx. Ctx is not always an FPMathOperator, so explicitly check for it. Fixes #71548.
- Loading branch information
1 parent
551c280
commit f0cdf4b
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6606,7 +6606,8 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, | |
// float, if the ninf flag is set. | ||
const APFloat *C; | ||
if (match(Op1, m_APFloat(C)) && | ||
(C->isInfinity() || (Q.CxtI->hasNoInfs() && C->isLargest()))) { | ||
(C->isInfinity() || (isa<FPMathOperator>(Q.CxtI) && | ||
Q.CxtI->hasNoInfs() && C->isLargest()))) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nikic
Contributor
|
||
// minnum(X, -inf) -> -inf | ||
// maxnum(X, +inf) -> +inf | ||
// minimum(X, -inf) -> -inf if nnan | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't think this is the right fix. This code is just wrong.
Q.CxtI
is some random instruction, it's not necessarily theminnum
call being simplified. As such, checking flags on it is meaningless.What we need to do instead is to pass down the
Call
fromsimplifyIntrinsic()
and then check the flags on that.