[llvm-commits] [llvm] r72872 - in /llvm/trunk/lib: CodeGen/SelectionDAG/DAGCombiner.cpp CodeGen/SelectionDAG/SelectionDAG.cpp Transforms/Scalar/InstructionCombining.cpp
Bill Wendling
isanbard at gmail.com
Thu Jun 4 11:11:50 PDT 2009
Please look at this test which is now failing because of this change:
Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/Transforms/InstCombine/dg.exp
...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/Transforms/InstCombine/mul.ll
for PR2642
Failed with exit(1) at line 1
while running: llvm-as <
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/Transforms/InstCombine/mul.ll
| opt -instcombine | llvm-dis | not /usr/bin/grep mul
%3 = mul <4 x float> %2, zeroinitializer ; <<4 x float>> [#uses=1]
child process exited abnormally
-bw
On Thu, Jun 4, 2009 at 10:12 AM, Dan Gohman <gohman at apple.com> wrote:
> Author: djg
> Date: Thu Jun 4 12:12:12 2009
> New Revision: 72872
>
> URL: http://llvm.org/viewvc/llvm-project?rev=72872&view=rev
> Log:
> Don't do the X * 0.0 -> 0.0 transformation in instcombine, because
> instcombine doesn't know when it's safe. To partially compensate
> for this, introduce new code to do this transformation in
> dagcombine, which can use UnsafeFPMath.
>
> Modified:
> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=72872&r1=72871&r2=72872&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Jun 4 12:12:12 2009
> @@ -4019,6 +4019,9 @@
> // fold (fmul A, 0) -> 0
> if (UnsafeFPMath && N1CFP && N1CFP->getValueAPF().isZero())
> return N1;
> + // fold (fmul A, 0) -> 0, vector edition.
> + if (UnsafeFPMath && ISD::isBuildVectorAllZeros(N1.getNode()))
> + return N1;
> // fold (fmul X, 2.0) -> (fadd X, X)
> if (N1CFP && N1CFP->isExactlyValue(+2.0))
> return DAG.getNode(ISD::FADD, N->getDebugLoc(), VT, N0, N0);
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=72872&r1=72871&r2=72872&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Jun 4 12:12:12 2009
> @@ -2807,16 +2807,19 @@
> case ISD::ADDC:
> case ISD::ADDE:
> case ISD::SUB:
> - case ISD::FADD:
> - case ISD::FSUB:
> - case ISD::FMUL:
> - case ISD::FDIV:
> - case ISD::FREM:
> case ISD::UDIV:
> case ISD::SDIV:
> case ISD::UREM:
> case ISD::SREM:
> return N2; // fold op(arg1, undef) -> undef
> + case ISD::FADD:
> + case ISD::FSUB:
> + case ISD::FMUL:
> + case ISD::FDIV:
> + case ISD::FREM:
> + if (UnsafeFPMath)
> + return N2;
> + break;
> case ISD::MUL:
> case ISD::AND:
> case ISD::SRL:
>
> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=72872&r1=72871&r2=72872&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Jun 4 12:12:12 2009
> @@ -2585,7 +2585,9 @@
> bool Changed = SimplifyCommutative(I);
> Value *Op0 = I.getOperand(0);
>
> - if (isa<UndefValue>(I.getOperand(1))) // undef * X -> 0
> + // TODO: If Op1 is undef and Op0 is finite, return zero.
> + if (!I.getType()->isFPOrFPVector() &&
> + isa<UndefValue>(I.getOperand(1))) // undef * X -> 0
> return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
>
> // Simplify mul instructions with a constant RHS...
> @@ -2612,16 +2614,14 @@
> ConstantInt::get(Op0->getType(), Val.logBase2()));
> }
> } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
> - if (Op1F->isNullValue())
> - return ReplaceInstUsesWith(I, Op1);
> + // TODO: If Op1 is zero and Op0 is finite, return zero.
>
> // "In IEEE floating point, x*1 is not equivalent to x for nans. However,
> // ANSI says we can drop signals, so we can do this anyway." (from GCC)
> if (Op1F->isExactlyValue(1.0))
> return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
> } else if (isa<VectorType>(Op1->getType())) {
> - if (isa<ConstantAggregateZero>(Op1))
> - return ReplaceInstUsesWith(I, Op1);
> + // TODO: If Op1 is all zeros and Op0 is all finite, return all zeros.
>
> if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1)) {
> if (Op1V->isAllOnesValue()) // X * -1 == 0 - X
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list