Skip to content

Commit cf30539

Browse files
committed
[DAGCombiner] Update for hasNoSignedZeros.
1 parent e56ba95 commit cf30539

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16737,8 +16737,10 @@ SDValue DAGCombiner::visitFADDForFMACombine(SDNode *N) {
1673716737
}
1673816738

1673916739
// fold (fadd (freeze (fmul x, y)), z) -> (fma x, y, z).
16740-
if ((Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
16741-
N0.getOpcode() == ISD::FREEZE) {
16740+
bool CanContract =
16741+
(Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
16742+
(Options.NoSignedZerosFPMath || N->getFlags().hasNoSignedZeros());
16743+
if (CanContract && N0.getOpcode() == ISD::FREEZE) {
1674216744
SDValue FrozenMul = N0.getOperand(0);
1674316745
if (matcher.match(FrozenMul, ISD::FMUL) && isContractableFMUL(FrozenMul)) {
1674416746
SDValue X = FrozenMul.getOperand(0);
@@ -16748,8 +16750,7 @@ SDValue DAGCombiner::visitFADDForFMACombine(SDNode *N) {
1674816750
}
1674916751

1675016752
// fold (fadd x, (freeze (fmul y, z))) -> (fma y, z, x)
16751-
if ((Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
16752-
N1.getOpcode() == ISD::FREEZE) {
16753+
if (CanContract && N1.getOpcode() == ISD::FREEZE) {
1675316754
SDValue FrozenMul = N1.getOperand(0);
1675416755
if (matcher.match(FrozenMul, ISD::FMUL) && isContractableFMUL(FrozenMul)) {
1675516756
SDValue X = FrozenMul.getOperand(0);
@@ -17036,8 +17037,10 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
1703617037
}
1703717038

1703817039
// fold (fsub (freeze (fmul x, y)), z) -> (fma x, y, (fneg z))
17039-
if ((Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
17040-
N0.getOpcode() == ISD::FREEZE) {
17040+
bool CanContract =
17041+
(Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
17042+
(Options.NoSignedZerosFPMath || N->getFlags().hasNoSignedZeros());
17043+
if (CanContract && N0.getOpcode() == ISD::FREEZE) {
1704117044
SDValue FrozenMul = N0.getOperand(0);
1704217045
if (matcher.match(FrozenMul, ISD::FMUL) && isContractableFMUL(FrozenMul)) {
1704317046
SDValue X = FrozenMul.getOperand(0);
@@ -17048,8 +17051,7 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
1704817051
}
1704917052

1705017053
// fold (fsub z, (freeze(fmul x, y))) -> (fma (fneg x), y, z)
17051-
if ((Options.UnsafeFPMath || N->getFlags().hasAllowContract()) &&
17052-
N1.getOpcode() == ISD::FREEZE) {
17054+
if (CanContract && N1.getOpcode() == ISD::FREEZE) {
1705317055
SDValue FrozenMul = N1.getOperand(0);
1705417056
if (matcher.match(FrozenMul, ISD::FMUL) && isContractableFMUL(FrozenMul)) {
1705517057
SDValue X = FrozenMul.getOperand(0);

0 commit comments

Comments
 (0)