llvm.org GIT mirror llvm / 3190427
[InstCombine] simplify code for X * -1.0 --> -X; NFC I've added random FMF to one of the tests to show those are propagated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326377 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
2 changed file(s) with 5 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
562562 if (match(Op0, m_FNeg(m_Value(X))))
563563 return BinaryOperator::CreateFMulFMF(X, ConstantExpr::getFNeg(C), &I);
564564
565 // (fmul X, -1.0) --> (fsub -0.0, X)
566 if (match(C, m_SpecificFP(-1.0))) {
567 Constant *NegZero = ConstantFP::getNegativeZero(Op1->getType());
568 Instruction *RI = BinaryOperator::CreateFSub(NegZero, Op0);
569 RI->copyFastMathFlags(&I);
570 return RI;
571 }
565 // X * -1.0 --> -X
566 if (match(C, m_SpecificFP(-1.0)))
567 return BinaryOperator::CreateFNegFMF(Op0, &I);
572568
573569 if (AllowReassociate && C->isFiniteNonZeroFP()) {
574570 // Let MDC denote an expression in one of these forms:
152152 ; PR18532
153153 define <4 x float> @test10(<4 x float> %x) {
154154 ; CHECK-LABEL: @test10(
155 ; CHECK-NEXT: [[MUL:%.*]] = fsub <4 x float> , [[X:%.*]]
155 ; CHECK-NEXT: [[MUL:%.*]] = fsub arcp afn <4 x float> , [[X:%.*]]
156156 ; CHECK-NEXT: ret <4 x float> [[MUL]]
157157 ;
158 %mul = fmul <4 x float> %x,
158 %mul = fmul arcp afn <4 x float> %x,
159159 ret <4 x float> %mul
160160 }
161161