llvm.org GIT mirror
[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).
 562 562 if (match(Op0, m_FNeg(m_Value(X)))) 563 563 return BinaryOperator::CreateFMulFMF(X, ConstantExpr::getFNeg(C), &I); 564 564 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); 572 568 573 569 if (AllowReassociate && C->isFiniteNonZeroFP()) { 574 570 // Let MDC denote an expression in one of these forms:
 152 152 ; PR18532 153 153 define <4 x float> @test10(<4 x float> %x) { 154 154 ; CHECK-LABEL: @test10( 155 ; CHECK-NEXT: [[MUL:%.*]] = fsub <4 x float> , [[X:%.*]]⏎ 155 ; CHECK-NEXT: [[MUL:%.*]] = fsub arcp afn <4 x float> , [[X:%.*]]⏎ 156 156 ; CHECK-NEXT: ret <4 x float> [[MUL]] 157 157 ; 158 %mul = fmul <4 x float> %x, ⏎ 158 %mul = fmul arcp afn <4 x float> %x, ⏎ 159 159 ret <4 x float> %mul 160 160 } 161 161