diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-09-10 18:52:08 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-09-10 18:52:08 +0000 |
| commit | e3fb157234c40dfa2746dbb08edd8730cc4b78c4 (patch) | |
| tree | c95a6e213a999204b7ad635fb3fde0ae2f60e56b /llvm | |
| parent | 677727e8296a802385345db6fa65e68223f4597a (diff) | |
Diffstat (limited to 'llvm')
19 files changed, 153 insertions, 88 deletions
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h index 8f71ce9e96c0..af8e8d22269e 100644 --- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -253,6 +253,8 @@ public: return {}; } + const Loop *getInnermostLoop() const { return InnermostLoop; } + private: /// A wrapper around ScalarEvolution, used to add runtime SCEV checks, and /// applies dynamic knowledge to simplify SCEV expressions and convert them diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 61520c4f29bf..c20ce79ee4d0 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -190,7 +190,8 @@ private: SmallString<128> CompilationDir; /// Prefix replacement map for source file information. - std::map<const std::string, const std::string> DebugPrefixMap; + std::map<std::string, const std::string, std::greater<std::string>> + DebugPrefixMap; /// The main file name if passed in explicitly. std::string MainFileName; @@ -698,6 +699,9 @@ public: /// Add an entry to the debug prefix map. void addDebugPrefixMapEntry(const std::string &From, const std::string &To); + /// Remap one path in-place as per the debug prefix map. + void remapDebugPath(SmallVectorImpl<char> &Path); + // Remaps all debug directory paths in-place as per the debug prefix map. void RemapDebugPaths(); diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h index 8b2ae84749b4..557c713575e4 100644 --- a/llvm/include/llvm/MC/MCDwarf.h +++ b/llvm/include/llvm/MC/MCDwarf.h @@ -22,6 +22,7 @@ #include "llvm/MC/StringTableBuilder.h" #include "llvm/Support/Error.h" #include "llvm/Support/MD5.h" +#include "llvm/Support/StringSaver.h" #include <cassert> #include <cstdint> #include <string> @@ -48,6 +49,8 @@ MCSymbol *emitListsTableHeaderStart(MCStreamer &S); /// Manage the .debug_line_str section contents, if we use it. class MCDwarfLineStr { + BumpPtrAllocator Alloc; + StringSaver Saver{Alloc}; MCSymbol *LineStrLabel = nullptr; StringTableBuilder LineStrings{StringTableBuilder::DWARF}; bool UseRelocs = false; @@ -57,6 +60,8 @@ public: /// v5 line table). explicit MCDwarfLineStr(MCContext &Ctx); + StringSaver &getSaver() { return Saver; } + /// Emit a reference to the string. void emitRef(MCStreamer *MCOS, StringRef Path); @@ -382,6 +387,7 @@ public: bool hasRootFile() const { return !Header.RootFile.Name.empty(); } + MCDwarfFile &getRootFile() { return Header.RootFile; } const MCDwarfFile &getRootFile() const { return Header.RootFile; } // Report whether MD5 usage has been consistent (all-or-none). diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index aa35f253bc5f..8311b480ab09 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -280,7 +280,8 @@ void RuntimePointerChecking::tryToCreateDiffCheck( auto *SrcAR = dyn_cast<SCEVAddRecExpr>(Src->Expr); auto *SinkAR = dyn_cast<SCEVAddRecExpr>(Sink->Expr); - if (!SrcAR || !SinkAR) { + if (!SrcAR || !SinkAR || SrcAR->getLoop() != DC.getInnermostLoop() || + SinkAR->getLoop() != DC.getInnermostLoop()) { CanUseDiffCheck = false; return; } diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8d465b9520de..42a141e8876b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6360,7 +6360,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 = @@ -7573,6 +7574,10 @@ SDValue DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) { std::swap(LHSMask, RHSMask); } + // Something has gone wrong - we've lost the shl/srl pair - bail. + if (LHSShift.getOpcode() != ISD::SHL || RHSShift.getOpcode() != ISD::SRL) + return SDValue(); + unsigned EltSizeInBits = VT.getScalarSizeInBits(); SDValue LHSShiftArg = LHSShift.getOperand(0); SDValue LHSShiftAmt = LHSShift.getOperand(1); @@ -22729,25 +22734,31 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { SDLoc DL(N); EVT IntVT = VT.changeVectorElementTypeToInteger(); EVT IntSVT = VT.getVectorElementType().changeTypeToInteger(); - IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT); - SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT); - SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT); - SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT)); - for (int I = 0; I != (int)NumElts; ++I) - if (0 <= Mask[I]) - AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt; - - // See if a clear mask is legal instead of going via - // XformToShuffleWithZero which loses UNDEF mask elements. - if (TLI.isVectorClearMaskLegal(ClearMask, IntVT)) - return DAG.getBitcast( - VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0), - DAG.getConstant(0, DL, IntVT), ClearMask)); - - if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT)) - return DAG.getBitcast( - VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0), - DAG.getBuildVector(IntVT, DL, AndMask))); + // Transform the type to a legal type so that the buildvector constant + // elements are not illegal. Make sure that the result is larger than the + // original type, incase the value is split into two (eg i64->i32). + if (!TLI.isTypeLegal(IntSVT) && LegalTypes) + IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT); + if (IntSVT.getSizeInBits() >= IntVT.getScalarSizeInBits()) { + SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT); + SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT); + SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT)); + for (int I = 0; I != (int)NumElts; ++I) + if (0 <= Mask[I]) + AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt; + + // See if a clear mask is legal instead of going via + // XformToShuffleWithZero which loses UNDEF mask elements. + if (TLI.isVectorClearMaskLegal(ClearMask, IntVT)) + return DAG.getBitcast( + VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0), + DAG.getConstant(0, DL, IntVT), ClearMask)); + + if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT)) + return DAG.getBitcast( + VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0), + DAG.getBuildVector(IntVT, DL, AndMask))); + } } } diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 228d4a43ccde..e2173879c218 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4428,7 +4428,10 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N, else if (VT == MVT::i128) LC = RTLIB::MULO_I128; - if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) { + // If we don't have the libcall or if the function we are compiling is the + // implementation of the expected libcall (avoid inf-loop), expand inline. + if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC) || + TLI.getLibcallName(LC) == DAG.getMachineFunction().getName()) { // FIXME: This is not an optimal expansion, but better than crashing. EVT WideVT = EVT::getIntegerVT(*DAG.getContext(), VT.getScalarSizeInBits() * 2); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index d2ed4fe018b5..5ea4c4cded7f 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -1382,10 +1382,12 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex( IncludeDir = dwarf::toStringRef(IncludeDirectories[Entry.DirIdx - 1]); } - // For absolute paths only, include the compilation directory of compile unit. - // We know that FileName is not absolute, the only way to have an absolute - // path at this point would be if IncludeDir is absolute. - if (Kind == FileLineInfoKind::AbsoluteFilePath && !CompDir.empty() && + // For absolute paths only, include the compilation directory of compile unit, + // unless v5 DirIdx == 0 (IncludeDir indicates the compilation directory). We + // know that FileName is not absolute, the only way to have an absolute path + // at this point would be if IncludeDir is absolute. + if (Kind == FileLineInfoKind::AbsoluteFilePath && + (getVersion() < 5 || Entry.DirIdx != 0) && !CompDir.empty() && !isPathAbsoluteOnWindowsOrPosix(IncludeDir)) sys::path::append(FilePath, Style, CompDir); diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 322ed8e23eb6..062246f9c7ee 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -855,30 +855,35 @@ void MCContext::addDebugPrefixMapEntry(const std::string &From, DebugPrefixMap.insert(std::make_pair(From, To)); } +void MCContext::remapDebugPath(SmallVectorImpl<char> &Path) { + for (const auto &V : DebugPrefixMap) + if (llvm::sys::path::replace_path_prefix(Path, V.first, V.second)) + break; +} + void MCContext::RemapDebugPaths() { const auto &DebugPrefixMap = this->DebugPrefixMap; if (DebugPrefixMap.empty()) return; - const auto RemapDebugPath = [&DebugPrefixMap](std::string &Path) { - SmallString<256> P(Path); - for (const auto &Entry : DebugPrefixMap) { - if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second)) { - Path = P.str().str(); - break; - } + // Remap compilation directory. + remapDebugPath(CompilationDir); + + // Remap MCDwarfDirs and RootFile.Name in all compilation units. + SmallString<256> P; + for (auto &CUIDTablePair : MCDwarfLineTablesCUMap) { + for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs()) { + P = Dir; + remapDebugPath(P); + Dir = std::string(P); } - }; - // Remap compilation directory. - std::string CompDir = std::string(CompilationDir.str()); - RemapDebugPath(CompDir); - CompilationDir = CompDir; - - // Remap MCDwarfDirs in all compilation units. - for (auto &CUIDTablePair : MCDwarfLineTablesCUMap) - for (auto &Dir : CUIDTablePair.second.getMCDwarfDirs()) - RemapDebugPath(Dir); + // Used by DW_TAG_compile_unit's DT_AT_name and DW_TAG_label's + // DW_AT_decl_file for DWARF v5 generated for assembly source. + P = CUIDTablePair.second.getRootFile().Name; + remapDebugPath(P); + CUIDTablePair.second.getRootFile().Name = std::string(P); + } } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 4cbb9981fde2..cc1a662da87e 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -266,7 +266,7 @@ void MCDwarfLineTable::emit(MCStreamer *MCOS, MCDwarfLineTableParams Params) { // In a v5 non-split line table, put the strings in a separate section. Optional<MCDwarfLineStr> LineStr; if (context.getDwarfVersion() >= 5) - LineStr = MCDwarfLineStr(context); + LineStr.emplace(context); // Switch to the section where the table will be emitted into. MCOS->switchSection(context.getObjectFileInfo()->getDwarfLineSection()); @@ -416,9 +416,15 @@ void MCDwarfLineTableHeader::emitV5FileDirTables( : dwarf::DW_FORM_string); MCOS->emitULEB128IntValue(MCDwarfDirs.size() + 1); // Try not to emit an empty compilation directory. - const StringRef CompDir = CompilationDir.empty() - ? MCOS->getContext().getCompilationDir() - : StringRef(CompilationDir); + SmallString<256> Dir; + StringRef CompDir = MCOS->getContext().getCompilationDir(); + if (!CompilationDir.empty()) { + Dir = CompilationDir; + MCOS->getContext().remapDebugPath(Dir); + CompDir = Dir.str(); + if (LineStr) + CompDir = LineStr->getSaver().save(CompDir); + } if (LineStr) { // Record path strings, emit references here. LineStr->emitRef(MCOS, CompDir); diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 563d3487ef50..38977b7641a0 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -566,8 +566,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { } if (getLexer().isNot(AsmToken::String)) { - if (!getContext().getAsmInfo()->usesSunStyleELFSectionSwitchSyntax() - || getLexer().isNot(AsmToken::Hash)) + if (getLexer().isNot(AsmToken::Hash)) return TokError("expected string in directive"); extraFlags = parseSunStyleSectionFlags(); } else { diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index c97f273b0739..94a1536f4690 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -1734,6 +1734,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) { bool HasExtLeaf8 = MaxExtLevel >= 0x80000008 && !getX86CpuIDAndInfo(0x80000008, &EAX, &EBX, &ECX, &EDX); Features["clzero"] = HasExtLeaf8 && ((EBX >> 0) & 1); + Features["rdpru"] = HasExtLeaf8 && ((EBX >> 4) & 1); Features["wbnoinvd"] = HasExtLeaf8 && ((EBX >> 9) & 1); bool HasLeaf7 = diff --git a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp index a19253da440e..1b5bd4c00089 100644 --- a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp +++ b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp @@ -71,7 +71,7 @@ bool RISCVCodeGenPrepare::optimizeZExt(ZExtInst *ZExt) { // This often occurs with widened induction variables. if (isImpliedByDomCondition(ICmpInst::ICMP_SGE, Src, Constant::getNullValue(Src->getType()), ZExt, - *DL)) { + *DL).value_or(false)) { auto *SExt = new SExtInst(Src, ZExt->getType(), "", ZExt); SExt->takeName(ZExt); SExt->setDebugLoc(ZExt->getDebugLoc()); @@ -140,7 +140,7 @@ bool RISCVCodeGenPrepare::optimizeAndExt(BinaryOperator *BO) { // And mask constant. if (!isImpliedByDomCondition(ICmpInst::ICMP_SGE, LHSSrc, Constant::getNullValue(LHSSrc->getType()), - LHS, *DL)) + LHS, *DL).value_or(false)) return false; // Sign extend the constant and replace the And operand. diff --git a/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp index 27d1326d5f6c..7b63b060dd9c 100644 --- a/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp +++ b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp @@ -21,8 +21,8 @@ Target &llvm::getTheRISCV64Target() { } extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetInfo() { - RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32", - "32-bit RISC-V", "RISCV"); - RegisterTarget<Triple::riscv64> Y(getTheRISCV64Target(), "riscv64", - "64-bit RISC-V", "RISCV"); + RegisterTarget<Triple::riscv32, /*HasJIT=*/true> X( + getTheRISCV32Target(), "riscv32", "32-bit RISC-V", "RISCV"); + RegisterTarget<Triple::riscv64, /*HasJIT=*/true> Y( + getTheRISCV64Target(), "riscv64", "64-bit RISC-V", "RISCV"); } diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp index c5cc2ea34bb7..c4545ff56f74 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp @@ -40,7 +40,6 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple &TheTriple) { ExceptionsType = ExceptionHandling::DwarfCFI; - SunStyleELFSectionSwitchSyntax = true; UsesELFSectionDirectiveForBSS = true; } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 7d0fc4e8a8c6..cd45c48259bb 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -1362,6 +1362,8 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setOperationAction(ISD::SINT_TO_FP, MVT::v8i32, Custom); setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v8i32, Custom); + setOperationAction(ISD::FP_EXTEND, MVT::v8f32, Expand); + setOperationAction(ISD::FP_ROUND, MVT::v8f16, Expand); setOperationAction(ISD::FP_EXTEND, MVT::v4f64, Custom); setOperationAction(ISD::STRICT_FP_EXTEND, MVT::v4f64, Custom); @@ -1519,7 +1521,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, // Extract subvector is special because the value type // (result) is 128-bit but the source is 256-bit wide. for (auto VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64, - MVT::v4f32, MVT::v2f64 }) { + MVT::v8f16, MVT::v4f32, MVT::v2f64 }) { setOperationAction(ISD::EXTRACT_SUBVECTOR, VT, Legal); } @@ -1859,7 +1861,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, // (result) is 256-bit but the source is 512-bit wide. // 128-bit was made Legal under AVX1. for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64, - MVT::v8f32, MVT::v4f64 }) + MVT::v16f16, MVT::v8f32, MVT::v4f64 }) setOperationAction(ISD::EXTRACT_SUBVECTOR, VT, Legal); for (auto VT : { MVT::v64i8, MVT::v32i16, MVT::v16i32, MVT::v8i64, @@ -16120,16 +16122,18 @@ static SDValue lowerV8F16Shuffle(const SDLoc &DL, ArrayRef<int> Mask, assert(Mask.size() == 8 && "Unexpected mask size for v8 shuffle!"); int NumV2Elements = count_if(Mask, [](int M) { return M >= 8; }); - if (NumV2Elements == 0) { - // Check for being able to broadcast a single element. - if (SDValue Broadcast = lowerShuffleAsBroadcast(DL, MVT::v8f16, V1, V2, - Mask, Subtarget, DAG)) - return Broadcast; + if (Subtarget.hasFP16()) { + if (NumV2Elements == 0) { + // Check for being able to broadcast a single element. + if (SDValue Broadcast = lowerShuffleAsBroadcast(DL, MVT::v8f16, V1, V2, + Mask, Subtarget, DAG)) + return Broadcast; + } + if (NumV2Elements == 1 && Mask[0] >= 8) + if (SDValue V = lowerShuffleAsElementInsertion( + DL, MVT::v8f16, V1, V2, Mask, Zeroable, Subtarget, DAG)) + return V; } - if (NumV2Elements == 1 && Mask[0] >= 8) - if (SDValue V = lowerShuffleAsElementInsertion(DL, MVT::v8f16, V1, V2, Mask, - Zeroable, Subtarget, DAG)) - return V; V1 = DAG.getBitcast(MVT::v8i16, V1); V2 = DAG.getBitcast(MVT::v8i16, V2); @@ -32701,8 +32705,29 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N, N->getOpcode() == ISD::STRICT_FP_TO_SINT; EVT VT = N->getValueType(0); SDValue Src = N->getOperand(IsStrict ? 1 : 0); + SDValue Chain = IsStrict ? N->getOperand(0) : SDValue(); EVT SrcVT = Src.getValueType(); + SDValue Res; + if (isSoftFP16(SrcVT)) { + EVT NVT = VT.isVector() ? VT.changeVectorElementType(MVT::f32) : MVT::f32; + if (IsStrict) { + Res = + DAG.getNode(N->getOpcode(), dl, {VT, MVT::Other}, + {Chain, DAG.getNode(ISD::STRICT_FP_EXTEND, dl, + {NVT, MVT::Other}, {Chain, Src})}); + Chain = Res.getValue(1); + } else { + Res = DAG.getNode(N->getOpcode(), dl, VT, + DAG.getNode(ISD::FP_EXTEND, dl, NVT, Src)); + } + Results.push_back(Res); + if (IsStrict) + Results.push_back(Chain); + + return; + } + if (VT.isVector() && Subtarget.hasFP16() && SrcVT.getVectorElementType() == MVT::f16) { EVT EleVT = VT.getVectorElementType(); @@ -32716,7 +32741,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N, Src = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v8f16, Ops); } - SDValue Res, Chain; if (IsStrict) { unsigned Opc = IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI; @@ -32908,7 +32932,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N, return; } - SDValue Chain; if (SDValue V = FP_TO_INTHelper(SDValue(N, 0), DAG, IsSigned, Chain)) { Results.push_back(V); if (IsStrict) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 158d2e8289e0..edbd4091d1d2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2040,9 +2040,7 @@ Instruction *InstCombinerImpl::foldICmpMulConstant(ICmpInst &Cmp, NewC = ConstantInt::get( Mul->getType(), APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::DOWN)); - } - - if (Mul->hasNoUnsignedWrap()) { + } else if (Mul->hasNoUnsignedWrap()) { if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE) NewC = ConstantInt::get( Mul->getType(), diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 349063dd5e89..bbba76a5c5ef 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1394,7 +1394,10 @@ int llvm::rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, // and next SCEV may errneously get smaller cost. // Collect all the candidate PHINodes to be rewritten. - RewritePhiSet.emplace_back(PN, i, ExitValue, Inst, HighCost); + Instruction *InsertPt = + (isa<PHINode>(Inst) || isa<LandingPadInst>(Inst)) ? + &*Inst->getParent()->getFirstInsertionPt() : Inst; + RewritePhiSet.emplace_back(PN, i, ExitValue, InsertPt, HighCost); } } } diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 03087d8370d5..245f2d4e442a 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -89,10 +89,12 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr, // Fail for an invalid base (required by POSIX). return nullptr; + // Current offset into the original string to reflect in EndPtr. + size_t Offset = 0; // Strip leading whitespace. - for (unsigned i = 0; i != Str.size(); ++i) - if (!isSpace((unsigned char)Str[i])) { - Str = Str.substr(i); + for ( ; Offset != Str.size(); ++Offset) + if (!isSpace((unsigned char)Str[Offset])) { + Str = Str.substr(Offset); break; } @@ -108,6 +110,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr, if (Str.empty()) // Fail for a sign with nothing after it. return nullptr; + ++Offset; } // Set Max to the absolute value of the minimum (for signed), or @@ -127,6 +130,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr, return nullptr; Str = Str.drop_front(2); + Offset += 2; Base = 16; } else if (Base == 0) @@ -167,7 +171,7 @@ static Value *convertStrToInt(CallInst *CI, StringRef &Str, Value *EndPtr, if (EndPtr) { // Store the pointer to the end. - Value *Off = B.getInt64(Str.size()); + Value *Off = B.getInt64(Offset + Str.size()); Value *StrBeg = CI->getArgOperand(0); Value *StrEnd = B.CreateInBoundsGEP(B.getInt8Ty(), StrBeg, Off, "endptr"); B.CreateStore(StrEnd, EndPtr); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index d69d1e3d19f3..53c11c58f73d 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -4696,10 +4696,12 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, }; SmallVector<unsigned> SortedIndices; BasicBlock *BB = nullptr; + bool IsScatterVectorizeUserTE = + UserTreeIdx.UserTE && + UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize; bool AreAllSameInsts = (S.getOpcode() && allSameBlock(VL)) || - (S.OpValue->getType()->isPointerTy() && UserTreeIdx.UserTE && - UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize && + (S.OpValue->getType()->isPointerTy() && IsScatterVectorizeUserTE && VL.size() > 2 && all_of(VL, [&BB](Value *V) { @@ -4760,10 +4762,9 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, // Check that none of the instructions in the bundle are already in the tree. for (Value *V : VL) { - auto *I = dyn_cast<Instruction>(V); - if (!I) + if (!IsScatterVectorizeUserTE && !isa<Instruction>(V)) continue; - if (getTreeEntry(I)) { + if (getTreeEntry(V)) { LLVM_DEBUG(dbgs() << "SLP: The instruction (" << *V << ") is already in tree.\n"); if (TryToFindDuplicates(S)) @@ -5213,9 +5214,6 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, } } - bool IsScatterUser = - UserTreeIdx.UserTE && - UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize; // We don't combine GEPs with non-constant indexes. Type *Ty1 = VL0->getOperand(1)->getType(); for (Value *V : VL) { @@ -5223,9 +5221,9 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, if (!I) continue; auto *Op = I->getOperand(1); - if ((!IsScatterUser && !isa<ConstantInt>(Op)) || + if ((!IsScatterVectorizeUserTE && !isa<ConstantInt>(Op)) || (Op->getType() != Ty1 && - ((IsScatterUser && !isa<ConstantInt>(Op)) || + ((IsScatterVectorizeUserTE && !isa<ConstantInt>(Op)) || Op->getType()->getScalarSizeInBits() > DL->getIndexSizeInBits( V->getType()->getPointerAddressSpace())))) { |
