[X86] combineMulToPMADDWD - use ComputeMinSignedBits(). NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Nov 2021 15:02:27 +0000 (15:02 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Nov 2021 15:28:31 +0000 (15:28 +0000)
Use ComputeMinSignedBits() to ensure the mul source operands at least sign-extend down from the bottom 16 bits.

This will make it easier if/when we try to support handling of source types larger than 32-bits.

llvm/lib/Target/X86/X86ISelLowering.cpp

index 597f909..aa60a8c 100644 (file)
@@ -44466,8 +44466,8 @@ static SDValue combineMulToPMADDWD(SDNode *N, SelectionDAG &DAG,
        N1.getOperand(0).getScalarValueSizeInBits() <= 8))
     return SDValue();
 
-  // Sign bits must extend through the upper 17 bits.
-  if (DAG.ComputeNumSignBits(N1) < 17 || DAG.ComputeNumSignBits(N0) < 17)
+  // Sign bits must extend down to the lowest i16.
+  if (DAG.ComputeMinSignedBits(N1) > 16 || DAG.ComputeMinSignedBits(N0) > 16)
     return SDValue();
 
   // At least one of the elements must be zero in the upper 17 bits, or can be