Please review: Optimize vector multiply on X86

Demikhovsky, Elena elena.demikhovsky at intel.com
Sun Jun 16 06:00:23 PDT 2013


I check it before, I can add assert

    ConstantSDNode *N0C = 0;
    ConstantSDNode *N1C = 0;
    if (isSplatVector(LHS.getNode()))
      N0C = dyn_cast<ConstantSDNode>(LHS.getOperand(0).getNode());
    if (isSplatVector(RHS.getNode()))
      N1C = dyn_cast<ConstantSDNode>(RHS.getOperand(0).getNode());

    if (!N0C && !N1C)
      return SDValue();                                   <<= I guarantee that one operand  is constant

    // Canonicalize constant to RHS.
    SDValue N0 = LHS;
    SDValue N1 = RHS;
    if (N0C && !N1C) {
      N0 = RHS;
      N1 = LHS;                                            <<=  I put constant side to N1
    }
    // fold (mul x, 0) -> 0
    if (ISD::isBuildVectorAllZeros(N1.getNode()))
      return N1;

    // fold (mul x, -1) -> 0-x
    if (ISD::isBuildVectorAllOnes(N1.getNode()))
      return DAG.getNode(ISD::SUB, SDLoc(N), VT, DAG.getConstant(0, VT), N0);

    N1C = dyn_cast<ConstantSDNode>(N1.getOperand(0));           <<= at this point I know that N1 is constant, I can add assert

-  Elena

-----Original Message-----
From: Jakub Staszak [mailto:kubastaszak at gmail.com] 
Sent: Sunday, June 16, 2013 15:46
To: Demikhovsky, Elena
Cc: Jakub Staszak; llvm-commits at cs.uiuc.edu
Subject: Re: Please review: Optimize vector multiply on X86

Hi,

You should check whether N1C isn't NULL here:

+    N1C = dyn_cast<ConstantSDNode>(N1.getOperand(0));
+    // fold (mul x, 1) -> x
+    if (N1C->getAPIntValue() == 1)


Best,
Kuba

On Jun 16, 2013, at 2:22 PM, "Demikhovsky, Elena" <elena.demikhovsky at intel.com> wrote:

> <mul.diff>

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the llvm-commits mailing list