[llvm] r233482 - [DAGCombiner] Fixed incorrect test for buildvector of constant integers.
Justin Bogner
mail at justinbogner.com
Mon Mar 30 17:14:06 PDT 2015
Simon Pilgrim <llvm-dev at redking.me.uk> writes:
> Author: rksimon
> Date: Sat Mar 28 13:31:31 2015
> New Revision: 233482
>
> URL: http://llvm.org/viewvc/llvm-project?rev=233482&view=rev
> Log:
> [DAGCombiner] Fixed incorrect test for buildvector of constant integers.
>
> DAGCombiner::ReassociateOps was correctly testing for an constant
> integer scalar but failed to correctly test for constant integer
> vectors (it was testing for any constant vector).
Test case?
> Modified:
> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=233482&r1=233481&r2=233482&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Mar 28 13:31:31 2015
> @@ -705,16 +705,8 @@ static bool isConstantSplatVector(SDNode
> EltVT.getSizeInBits() >= SplatBitSize);
> }
>
> -// \brief Returns the SDNode if it is a constant BuildVector or constant.
> -static SDNode *isConstantBuildVectorOrConstantInt(SDValue N) {
> - if (isa<ConstantSDNode>(N))
> - return N.getNode();
> - BuildVectorSDNode *BV = dyn_cast<BuildVectorSDNode>(N);
> - if (BV && BV->isConstant())
> - return BV;
> - return nullptr;
> -}
> -
> +// \brief Returns the SDNode if it is a constant integer BuildVector
> +// or constant integer.
> static SDNode *isConstantIntBuildVectorOrConstantInt(SDValue N) {
> if (isa<ConstantSDNode>(N))
> return N.getNode();
> @@ -723,6 +715,8 @@ static SDNode *isConstantIntBuildVectorO
> return nullptr;
> }
>
> +// \brief Returns the SDNode if it is a constant float BuildVector
> +// or constant float.
> static SDNode *isConstantFPBuildVectorOrConstantFP(SDValue N) {
> if (isa<ConstantFPSDNode>(N))
> return N.getNode();
> @@ -773,8 +767,8 @@ SDValue DAGCombiner::ReassociateOps(unsi
> SDValue N0, SDValue N1) {
> EVT VT = N0.getValueType();
> if (N0.getOpcode() == Opc) {
> - if (SDNode *L = isConstantBuildVectorOrConstantInt(N0.getOperand(1))) {
> - if (SDNode *R = isConstantBuildVectorOrConstantInt(N1)) {
> + if (SDNode *L = isConstantIntBuildVectorOrConstantInt(N0.getOperand(1))) {
> + if (SDNode *R = isConstantIntBuildVectorOrConstantInt(N1)) {
> // reassoc. (op (op x, c1), c2) -> (op x, (op c1, c2))
> if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, L, R))
> return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode);
> @@ -793,8 +787,8 @@ SDValue DAGCombiner::ReassociateOps(unsi
> }
>
> if (N1.getOpcode() == Opc) {
> - if (SDNode *R = isConstantBuildVectorOrConstantInt(N1.getOperand(1))) {
> - if (SDNode *L = isConstantBuildVectorOrConstantInt(N0)) {
> + if (SDNode *R = isConstantIntBuildVectorOrConstantInt(N1.getOperand(1))) {
> + if (SDNode *L = isConstantIntBuildVectorOrConstantInt(N0)) {
> // reassoc. (op c2, (op x, c1)) -> (op x, (op c1, c2))
> if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, VT, R, L))
> return DAG.getNode(Opc, DL, VT, N1.getOperand(0), OpNode);
>
>
> _______________________________________________
> 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