DAGCombiner.cpp (280031) | DAGCombiner.cpp (283526) |
---|---|
1//===-- DAGCombiner.cpp - Implement a DAG node combiner -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1146 unchanged lines hidden (view full) --- 1155//===----------------------------------------------------------------------===// 1156 1157void DAGCombiner::Run(CombineLevel AtLevel) { 1158 // set the instance variables, so that the various visit routines may use it. 1159 Level = AtLevel; 1160 LegalOperations = Level >= AfterLegalizeVectorOps; 1161 LegalTypes = Level >= AfterLegalizeTypes; 1162 | 1//===-- DAGCombiner.cpp - Implement a DAG node combiner -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1146 unchanged lines hidden (view full) --- 1155//===----------------------------------------------------------------------===// 1156 1157void DAGCombiner::Run(CombineLevel AtLevel) { 1158 // set the instance variables, so that the various visit routines may use it. 1159 Level = AtLevel; 1160 LegalOperations = Level >= AfterLegalizeVectorOps; 1161 LegalTypes = Level >= AfterLegalizeTypes; 1162 |
1163 // Early exit if this basic block is in an optnone function. 1164 AttributeSet FnAttrs = 1165 DAG.getMachineFunction().getFunction()->getAttributes(); 1166 if (FnAttrs.hasAttribute(AttributeSet::FunctionIndex, 1167 Attribute::OptimizeNone)) 1168 return; 1169 | |
1170 // Add all the dag nodes to the worklist. 1171 for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(), 1172 E = DAG.allnodes_end(); I != E; ++I) 1173 AddToWorklist(I); 1174 1175 // Create a dummy node (which is not added to allnodes), that adds a reference 1176 // to the root node, preventing it from being deleted, and tracking any 1177 // changes of the root. --- 1605 unchanged lines hidden (view full) --- 2783 // than the size of the vector lane, we need to re-expand it to 2784 // the lane size. 2785 if (BitWidth > SplatBitSize) 2786 for (SplatValue = SplatValue.zextOrTrunc(BitWidth); 2787 SplatBitSize < BitWidth; 2788 SplatBitSize = SplatBitSize * 2) 2789 SplatValue |= SplatValue.shl(SplatBitSize); 2790 | 1163 // Add all the dag nodes to the worklist. 1164 for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(), 1165 E = DAG.allnodes_end(); I != E; ++I) 1166 AddToWorklist(I); 1167 1168 // Create a dummy node (which is not added to allnodes), that adds a reference 1169 // to the root node, preventing it from being deleted, and tracking any 1170 // changes of the root. --- 1605 unchanged lines hidden (view full) --- 2776 // than the size of the vector lane, we need to re-expand it to 2777 // the lane size. 2778 if (BitWidth > SplatBitSize) 2779 for (SplatValue = SplatValue.zextOrTrunc(BitWidth); 2780 SplatBitSize < BitWidth; 2781 SplatBitSize = SplatBitSize * 2) 2782 SplatValue |= SplatValue.shl(SplatBitSize); 2783 |
2791 Constant = APInt::getAllOnesValue(BitWidth); 2792 for (unsigned i = 0, n = SplatBitSize/BitWidth; i < n; ++i) 2793 Constant &= SplatValue.lshr(i*BitWidth).zextOrTrunc(BitWidth); | 2784 // Make sure that variable 'Constant' is only set if 'SplatBitSize' is a 2785 // multiple of 'BitWidth'. Otherwise, we could propagate a wrong value. 2786 if (SplatBitSize % BitWidth == 0) { 2787 Constant = APInt::getAllOnesValue(BitWidth); 2788 for (unsigned i = 0, n = SplatBitSize/BitWidth; i < n; ++i) 2789 Constant &= SplatValue.lshr(i*BitWidth).zextOrTrunc(BitWidth); 2790 } |
2794 } 2795 } 2796 2797 // If we want to change an EXTLOAD to a ZEXTLOAD, ensure a ZEXTLOAD is 2798 // actually legal and isn't going to get expanded, else this is a false 2799 // optimisation. 2800 bool CanZextLoadProfitably = TLI.isLoadExtLegal(ISD::ZEXTLOAD, 2801 Load->getValueType(0), --- 8236 unchanged lines hidden (view full) --- 11038 // If we have two small inputs of the same type, try to concat them. 11039 VecIn1 = DAG.getNode(ISD::CONCAT_VECTORS, dl, VT, VecIn1, VecIn2); 11040 VecIn2 = SDValue(nullptr, 0); 11041 } else 11042 return SDValue(); 11043 } else if (VecInT.getSizeInBits() == VT.getSizeInBits() * 2) { 11044 // If the input vector is too large, try to split it. 11045 // We don't support having two input vectors that are too large. | 2791 } 2792 } 2793 2794 // If we want to change an EXTLOAD to a ZEXTLOAD, ensure a ZEXTLOAD is 2795 // actually legal and isn't going to get expanded, else this is a false 2796 // optimisation. 2797 bool CanZextLoadProfitably = TLI.isLoadExtLegal(ISD::ZEXTLOAD, 2798 Load->getValueType(0), --- 8236 unchanged lines hidden (view full) --- 11035 // If we have two small inputs of the same type, try to concat them. 11036 VecIn1 = DAG.getNode(ISD::CONCAT_VECTORS, dl, VT, VecIn1, VecIn2); 11037 VecIn2 = SDValue(nullptr, 0); 11038 } else 11039 return SDValue(); 11040 } else if (VecInT.getSizeInBits() == VT.getSizeInBits() * 2) { 11041 // If the input vector is too large, try to split it. 11042 // We don't support having two input vectors that are too large. |
11046 if (VecIn2.getNode()) | 11043 // If the zero vector was used, we can not split the vector, 11044 // since we'd need 3 inputs. 11045 if (UsesZeroVector || VecIn2.getNode()) |
11047 return SDValue(); 11048 11049 if (!TLI.isExtractSubvectorCheap(VT, VT.getVectorNumElements())) 11050 return SDValue(); 11051 11052 // Try to replace VecIn1 with two extract_subvectors 11053 // No need to update the masks, they should still be correct. 11054 VecIn2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, VecIn1, 11055 DAG.getConstant(VT.getVectorNumElements(), TLI.getVectorIdxTy())); 11056 VecIn1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, VecIn1, 11057 DAG.getConstant(0, TLI.getVectorIdxTy())); | 11046 return SDValue(); 11047 11048 if (!TLI.isExtractSubvectorCheap(VT, VT.getVectorNumElements())) 11049 return SDValue(); 11050 11051 // Try to replace VecIn1 with two extract_subvectors 11052 // No need to update the masks, they should still be correct. 11053 VecIn2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, VecIn1, 11054 DAG.getConstant(VT.getVectorNumElements(), TLI.getVectorIdxTy())); 11055 VecIn1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, VecIn1, 11056 DAG.getConstant(0, TLI.getVectorIdxTy())); |
11058 UsesZeroVector = false; | |
11059 } else 11060 return SDValue(); 11061 } 11062 11063 if (UsesZeroVector) 11064 VecIn2 = VT.isInteger() ? DAG.getConstant(0, VT) : 11065 DAG.getConstantFP(0.0, VT); 11066 else --- 1722 unchanged lines hidden --- | 11057 } else 11058 return SDValue(); 11059 } 11060 11061 if (UsesZeroVector) 11062 VecIn2 = VT.isInteger() ? DAG.getConstant(0, VT) : 11063 DAG.getConstantFP(0.0, VT); 11064 else --- 1722 unchanged lines hidden --- |