[InstCombine] Add check for flag propagation in foldSelectIntoOp
#173735
+19
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #162003 (comment).
The current flag propagation assumes that if a select has both
ninfandnnan, then the operands of the folded operation must be finite. While this assumption holds forfadd,fsub, andfmul, it does not hold forfdiv.For example, assume we have:
The current transform would turn
fdiv A, B; select ninf nnan cond, A/B, A;intoA / (select ninf nnan cond, B, 1.0). Ifcondis true, the inner select returnsB = +Inf, and due to the propagatedninf, this becomes poison.This patch add check for operators before flag propagation to avoid
fdivcases.Alive2: https://alive2.llvm.org/ce/z/o0MJmS