Skip to content

Commit db148eb

Browse files
committed
fold constant in visitFMUL
1 parent d4a1134 commit db148eb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17387,6 +17387,17 @@ SDValue DAGCombiner::visitFMUL(SDNode *N) {
1738717387
if (SDValue C = DAG.FoldConstantArithmetic(ISD::FMUL, DL, VT, {N0, N1}))
1738817388
return C;
1738917389

17390+
// fold (fmul N0 * 0.0) --> 0.0
17391+
if (DAG.getMachineFunction()
17392+
.getFunction()
17393+
.getFnAttribute("no-signed-zeros-fp-math")
17394+
.getValueAsBool() ||
17395+
Flags.hasNoSignedZeros()) {
17396+
ConstantFPSDNode *N1C = isConstOrConstSplatFP(N1, true);
17397+
if (N1C && N1C->isZero() && Flags.hasNoNaNs() && Flags.hasNoInfs())
17398+
return N1;
17399+
}
17400+
1739017401
// canonicalize constant to RHS
1739117402
if (DAG.isConstantFPBuildVectorOrConstantFP(N0) &&
1739217403
!DAG.isConstantFPBuildVectorOrConstantFP(N1))

0 commit comments

Comments
 (0)