llvm.org GIT mirror llvm / fe584de
[FPEnv] PatternMatcher support for checking FNEG ignoring signed zeros https://reviews.llvm.org/D52934 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344084 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 1 year, 12 days ago
3 changed file(s) with 10 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
663663 inline BinaryOp_match, RHS, Instruction::FSub>
664664 m_FNeg(const RHS &X) {
665665 return m_FSub(m_NegZeroFP(), X);
666 }
667
668 /// Match 'fneg X' as 'fsub +-0.0, X'.
669 template
670 inline BinaryOp_match, RHS, Instruction::FSub>
671 m_FNegNSZ(const RHS &X) {
672 return m_FSub(m_AnyZeroFP(), X);
666673 }
667674
668675 template
45074507 // -X / X -> -1.0 and
45084508 // X / -X -> -1.0 are legal when NaNs are ignored.
45094509 // We can ignore signed zeros because +-0.0/+-0.0 is NaN and ignored.
4510 if ((BinaryOperator::isFNeg(Op0, /*IgnoreZeroSign=*/true) &&
4511 BinaryOperator::getFNegArgument(Op0) == Op1) ||
4512 (BinaryOperator::isFNeg(Op1, /*IgnoreZeroSign=*/true) &&
4513 BinaryOperator::getFNegArgument(Op1) == Op0))
4510 if (match(Op0, m_FNegNSZ(m_Specific(Op1))) ||
4511 match(Op1, m_FNegNSZ(m_Specific(Op0))))
45144512 return ConstantFP::get(Op0->getType(), -1.0);
45154513 }
45164514
400400
401401 define <2 x float> @fdiv_neg_vec_undef_elt(<2 x float> %f) {
402402 ; CHECK-LABEL: @fdiv_neg_vec_undef_elt(
403 ; CHECK-NEXT: [[NEG:%.*]] = fsub <2 x float> , [[F:%.*]]
404 ; CHECK-NEXT: [[DIV:%.*]] = fdiv nnan <2 x float> [[F]], [[NEG]]
405 ; CHECK-NEXT: ret <2 x float> [[DIV]]
403 ; CHECK-NEXT: ret <2 x float>
406404 ;
407405 %neg = fsub <2 x float> , %f
408406 %div = fdiv nnan <2 x float> %f, %neg