@@ -54654,9 +54654,9 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
5465454654 return V;
5465554655
5465654656 // Fold trunc(srl(load(p),amt)) -> load(p+amt/8)
54657- // If we're shifting down whole byte+pow2 aligned bit chunks from a larger
54658- // load for truncation, see if we can convert the shift into a pointer
54659- // offset instead. Limit this to normal (non-ext) scalar integer loads.
54657+ // If we're shifting down byte aligned bit chunks from a larger load for
54658+ // truncation, see if we can convert the shift into a pointer offset instead.
54659+ // Limit this to normal (non-ext) scalar integer loads.
5466054660 if (SrcVT.isScalarInteger() && Src.getOpcode() == ISD::SRL &&
5466154661 Src.hasOneUse() && Src.getOperand(0).hasOneUse() &&
5466254662 ISD::isNormalLoad(Src.getOperand(0).getNode())) {
@@ -54665,9 +54665,9 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
5466554665 isPowerOf2_64(VT.getSizeInBits())) {
5466654666 SDValue ShAmt = Src.getOperand(1);
5466754667 KnownBits KnownAmt = DAG.computeKnownBits(ShAmt);
54668- // Check the shift amount is aligned to the truncated size .
54668+ // Check the shift amount is byte aligned .
5466954669 // Check the truncation doesn't use any shifted in (zero) top bits.
54670- if (KnownAmt.countMinTrailingZeros() >= Log2_64(VT.getSizeInBits()) &&
54670+ if (KnownAmt.countMinTrailingZeros() >= 3 &&
5467154671 KnownAmt.getMaxValue().ule(SrcVT.getSizeInBits() -
5467254672 VT.getSizeInBits())) {
5467354673 EVT PtrVT = Ld->getBasePtr().getValueType();
0 commit comments