llvm.org GIT mirror llvm / 10def39
Fold multiply by 0 or 1 when in UnsafeFPMath mode in SelectionDAG::getNode(). This folding happens as early as possible for performance reasons, and to make sure it isn't foiled by other transforms (e.g. forming FMAs). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163519 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Ilseman 8 years ago
1 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
28152815 if (ConstantFPSDNode *CFP = dyn_cast(N2))
28162816 if (CFP->getValueAPF().isZero())
28172817 return N1;
2818 } else if (Opcode == ISD::FMUL) {
2819 ConstantFPSDNode *CFP = dyn_cast(N1);
2820 SDValue V = N2;
2821
2822 // If the first operand isn't the constant, try the second
2823 if (!CFP) {
2824 CFP = dyn_cast(N2);
2825 V = N1;
2826 }
2827
2828 if (CFP) {
2829 // 0*x --> 0
2830 if (CFP->isZero())
2831 return SDValue(CFP,0);
2832 // 1*x --> x
2833 if (CFP->isExactlyValue(1.0))
2834 return V;
2835 }
28182836 }
28192837 }
28202838 assert(VT.isFloatingPoint() && "This operator only applies to FP types!");