From 898699831b5490d88b993593e5cb415fb2d1983a Mon Sep 17 00:00:00 2001 From: Peter Waller Date: Tue, 9 Aug 2022 15:13:50 +0000 Subject: [PATCH] [DAGCombine] Check zext legality in zext-extract-extend combine Discussed in D131503. Fix to D130782. --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 392b24a..17451b4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6378,7 +6378,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) { SDValue Extendee = Ext->getOperand(0); unsigned ScalarWidth = Extendee.getValueType().getScalarSizeInBits(); - if (N1C->getAPIntValue().isMask(ScalarWidth)) { + if (N1C->getAPIntValue().isMask(ScalarWidth) && + (!LegalOperations || TLI.isOperationLegal(ISD::ZERO_EXTEND, ExtVT))) { // (and (extract_subvector (zext|anyext|sext v) _) iN_mask) // => (extract_subvector (iN_zeroext v)) SDValue ZeroExtExtendee = -- 2.7.4