aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Instructions.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-11-06[IR] CmpInst: Add getFlippedSignednessPredicate()Roman Lebedev1-0/+12
And refactor a few places to use it
2020-11-06[IR] CmpInst: add isEquality(Pred)Roman Lebedev1-4/+6
Currently there is only a member version of isEquality(), which requires an actual [IF]CmpInst to be avaliable, which isn't always possible, and is inconsistent with the general pattern here. I wanted to use it in a new patch, but it wasn't there..
2020-11-06[IR] CmpInst: add getUnsignedPredicate()Roman Lebedev1-1/+18
There's already getSignedPredicate(), it is not symmetrical to not have it's opposite. I wanted to use it in new code, but it wasn't there..
2020-10-31Revert "Use uint64_t for branch weights instead of uint32_t"Arthur Eubanks1-5/+5
This reverts commit 10f2a0d662d8d72eaac48d3e9b31ca8dc90df5a4. More uint64_t overflows.
2020-10-30Use uint64_t for branch weights instead of uint32_tArthur Eubanks1-5/+5
CallInst::updateProfWeight() creates branch_weights with i64 instead of i32. To be more consistent everywhere and remove lots of casts from uint64_t to uint32_t, use i64 for branch_weights. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D88609
2020-10-27Revert "Use uint64_t for branch weights instead of uint32_t"Nico Weber1-5/+5
This reverts commit e5766f25c62c185632e3a75bf45b313eadab774b. Makes clang assert when building Chromium, see https://crbug.com/1142813 for a repro.
2020-10-26Use uint64_t for branch weights instead of uint32_tArthur Eubanks1-5/+5
CallInst::updateProfWeight() creates branch_weights with i64 instead of i32. To be more consistent everywhere and remove lots of casts from uint64_t to uint32_t, use i64 for branch_weights. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D88609
2020-10-07Add validity assert on entry to CastInst::isNoopCast [NFC]Philip Reames1-4/+2
This required some minor code reorganization to have a version of castIsValid which worked purely in terms of types.
2020-08-28[SVE] Make ElementCount members privateDavid Sherwood1-6/+7
This patch changes ElementCount so that the Min and Scalable members are now private and can only be accessed via the get functions getKnownMinValue() and isScalable(). In addition I've added some other member functions for more commonly used operations. Hopefully this makes the class more useful and will reduce the need for calling getKnownMinValue(). Differential Revision: https://reviews.llvm.org/D86065
2020-08-27[SVE] Remove calls to VectorType::getNumElements from IRChristopher Tetreault1-17/+33
Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D81500
2020-08-22[InstCombine] Remove unused entries in gc-live bundle of statepointSerguei Katkov1-0/+24
If some of gc live value are not used in gc.relocate we can remove them from gc-live bundle of statepoint instruction. Also the CL removes duplicated Values in gc-live bundle. Reviewers: reames, dantrushin Reviewed By: dantrushin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D85959
2020-08-19Revert "Revert "[NFC][llvm] Make the contructors of `ElementCount` private.""Mehdi Amini1-4/+4
Was reverted because MLIR/Flang builds were broken, these APIs have been fixed in the meantime.
2020-08-19Revert "[NFC][llvm] Make the contructors of `ElementCount` private."Mehdi Amini1-4/+4
This reverts commit 264afb9e6aebc98c353644dd0700bec808501cab. (and dependent 6b742cc48 and fc53bd610f) MLIR/Flang are broken.
2020-08-19[NFC][llvm] Make the contructors of `ElementCount` private.Francesco Petrogalli1-4/+4
Differential Revision: https://reviews.llvm.org/D86120
2020-07-14[IR] Add a few asserts to provide a better failure signature if you try to ↵Craig Topper1-0/+8
create a load/store/alloca with no alignment or insertion position If no alignment is specified we try to find the datalayout by using the insert position to get the module so we can get the datalayout. But if those are null, then we deference a null pointer. This patch adds asserts to make the failure a little more obvious than just seg faulting. Differential Revision: https://reviews.llvm.org/D83829
2020-07-07[NFC] Adding the align attribute on Atomic{CmpXchg|RMW}InstGuillaume Chatelet1-40/+25
This is the first step to add support for the align attribute to AtomicRMWInst and AtomicCmpXchgInst. Next step is to add support in IRBuilder and BitcodeReader. Bug: https://bugs.llvm.org/show_bug.cgi?id=27168 Differential Revision: https://reviews.llvm.org/D83136
2020-07-07[NFCI][IR] Introduce CallBase::Create() wrapperRoman Lebedev1-0/+14
Summary: It is reasonably common to want to clone some call with different bundles. Let's actually provide an interface to do that. Reviewers: chandlerc, jdoerfert, dblaikie, nickdesaulniers Reviewed By: nickdesaulniers Subscribers: llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D83248
2020-07-03[Alignment][NFC] Use 5 bits to store Instructions AlignmentGuillaume Chatelet1-16/+0
As per [MaxAlignmentExponent]{https://github.com/llvm/llvm-project/blob/b7338fb1a6a464472850211165391983d2c8fdf3/llvm/include/llvm/IR/Value.h#L688} alignment is not allowed to be more than 2^29. Encoded as Log2, this means that storing alignment uses 5 bits. This patch makes sure all instructions store their alignment in a consistent way, encoded as Log2 and using 5 bits. Differential Revision: https://reviews.llvm.org/D83119
2020-07-03[NFC] Use ADT/Bitfields in InstructionsGuillaume Chatelet1-12/+7
This is an example patch for D81580. Differential Revision: https://reviews.llvm.org/D81662
2020-07-01Make dyn_cast results explicitly auto* instead of just auto.Simon Pilgrim1-7/+7
Noticed by clang-tidy llvm-qualified-auto warning.
2020-06-30[Alignment][NFC] Migrate AtomicExpandPass to AlignGuillaume Chatelet1-0/+14
This is a followup on D78403. I'm unsure about `getAtomicOpAlign` overloads that take `AtomicRMWInst` and `AtomicCmpXchgInst`, shouldn't `getAlign` provide the correct answer already? Differential Revision: https://reviews.llvm.org/D81369
2020-06-17[SVE] Fix invalid usages of getNumElements in ShuffleVectorInstructionChristopher Tetreault1-2/+8
Summary: Fix invalid usages of getNumElements identified by test case LLVM.Transforms/InstCombine::vscale_extractelement.ll. changesLength: Since the length of the llvm::SmallVector shufflemask is related to the minimum number of elements in a scalable vector, it is fine to just get the Min field of the ElementCount isIdentityWithExtract: Since it is not possible to express the mask needed for this pattern for scalable vectors, we can just bail before calling getNumElements() Reviewers: efriedma, sdesmalen, fpetrogalli, gchatelet, yrouban, craig.topper Reviewed By: sdesmalen Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81969
2020-06-15[IR] Prefer hasFnAttribute() where possible (NFC)Nikita Popov1-2/+2
When checking for an enum function attribute, use hasFnAttribute() rather than hasAttribute() at FunctionIndex, because it is significantly faster (and more concise to boot).
2020-06-11[IR] Remove assert from ShuffleVectorInstSam Parker1-3/+8
Which triggers on valid, but not useful, IR such as a undef mask. Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=46276 Differential Revision: https://reviews.llvm.org/D81634
2020-05-29[SVE] Fix warnings in SelectInst::areInvalidOperandsDavid Sherwood1-1/+1
We should be comparing the element counts rather than the numbers of elements. Differential Revision: https://reviews.llvm.org/D80634
2020-05-19Give helpers internal linkage. NFC.Benjamin Kramer1-4/+4
2020-05-16AllocaInst should store Align instead of MaybeAlign.Eli Friedman1-15/+22
Along the lines of D77454 and D79968. Unlike loads and stores, the default alignment is getPrefTypeAlign, to match the existing handling in various places, including SelectionDAG and InstCombine. Differential Revision: https://reviews.llvm.org/D80044
2020-05-15StoreInst should store Align, not MaybeAlignEli Friedman1-18/+21
This is D77454, except for stores. All the infrastructure work was done for loads, so the remaining changes necessary are relatively small. Differential Revision: https://reviews.llvm.org/D79968
2020-05-14LoadInst should store Align, not MaybeAlign.Eli Friedman1-11/+21
The fact that loads and stores can have the alignment missing is a constant source of confusion: code that usually works can break down in rare cases. So fix the LoadInst API so the alignment is never missing. To reduce the number of changes required to make this work, IRBuilder and certain LoadInst constructors will grab the module's datalayout and compute the alignment automatically. This is the same alignment instcombine would eventually apply anyway; we're just doing it earlier. There's a minor risk that the way we're retrieving the datalayout could break out-of-tree code, but I don't think that's likely. This is the last in a series of patches, so most of the necessary changes have already been merged. Differential Revision: https://reviews.llvm.org/D77454
2020-05-04[SVE] Remove invalid usage of getNumElements in InstructionsChristopher Tetreault1-2/+2
Summary: Remove invalid usage of VectorType::getNumElements in ShuffleVectorInst::isValidOperands identified by test case llvm::Analysis/ConstantFolding/vscale-shufflevector.ll. The tested conditions hold for both fixed width and scalable vectors; use getElementCount(). Reviewers: efriedma, sdesmalen, c-rhodes, spatel Reviewed By: sdesmalen Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79212
2020-04-27[IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().Craig Topper1-10/+8
This method has been commented as deprecated for a while. Remove it and replace all uses with the equivalent getCalledOperand(). I also made a few cleanups in here. For example, to removes use of getElementType on a pointer when we could just use getFunctionType from the call. Differential Revision: https://reviews.llvm.org/D78882
2020-04-24[llvm][NFC][CallSite] Remove {Immutable}CallSite and CallSiteBaseMircea Trofin1-9/+0
Reviewers: dblaikie, craig.topper Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78794
2020-04-23[SVE] Remove calls to isScalable from IRChristopher Tetreault1-8/+7
Reviewers: efriedma, sdesmalen, dexonsmith, dblaikie Reviewed By: sdesmalen Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77691
2020-04-10Clean up usages of asserting vector getters in TypeChristopher Tetreault1-15/+19
Summary: Remove usages of asserting vector getters in Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: dexonsmith, sdesmalen, efriedma Reviewed By: efriedma Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77276
2020-04-06[CallSite Removal] a CallBase is never an IndirectCall for isInlineAsmNick Desaulniers1-4/+1
Summary: Thanks to Bill Wendling (void) for the report and steps to reproduce. It looks like this was missed during r350508's cleanup of the CallSite split into CallBase, CallInst, and CallBrInst. This was exposed by running pgo on a callbr, which was creating a ptrtoint to the inline asm thinking it was an indirect call. The relevant callchain looks like: IndirectCallPromotionPlugin::run() -> PGOIndirectCallVisitor::findIndirectCalls() -> PGOIndirectCallVisitor::visitCallBase() -> CallBase::isIndirectCall() Reviewers: void, chandlerc Reviewed By: void Subscribers: hiraditya, llvm-commits, craig.topper, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D77600
2020-03-31Remove "mask" operand from shufflevector.Eli Friedman1-48/+103
Instead, represent the mask as out-of-line data in the instruction. This should be more efficient in the places that currently use getShuffleVector(), and paves the way for further changes to add new shuffles for scalable vectors. This doesn't change the syntax in textual IR. And I don't currently plan to change the bitcode encoding in this patch, although we'll probably need to do something once we extend shufflevector for scalable types. I expect that once this is finished, we can then replace the raw "mask" with something more appropriate for scalable vectors. Not sure exactly what this looks like at the moment, but there are a few different ways we could handle it. Maybe we could try to describe specific shuffles. Or maybe we could define it in terms of a function to convert a fixed-length array into an appropriate scalable vector, using a "step", or something like that. Differential Revision: https://reviews.llvm.org/D72467
2020-03-30[llvm][IR][CastInst] Update `castIsValid` for scalable vectors.Francesco Petrogalli1-38/+26
Reviewers: sdesmalen Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76738
2020-03-30[ConstantFold][NFC] Compile time optimization for large vectorsThomas Raoux1-1/+5
Optimize the common case of splat vector constant. For large vector going through all elements is expensive. For splatr/broadcast cases we can skip going through all elements. Differential Revision: https://reviews.llvm.org/D76664
2020-03-18Remove CompositeType class.Eli Friedman1-28/+37
The existence of the class is more confusing than helpful, I think; the commonality is mostly just "GEP is legal", which can be queried using APIs on GetElementPtrInst. Differential Revision: https://reviews.llvm.org/D75660
2020-03-08[AssumeBundles] Add API to query a bundles from a useTyker1-0/+47
Summary: Finding what information is know about a value from a use is generally useful and can be done quickly. Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75616
2020-02-27Remove BinaryOperator::CreateFNegSimon Moll1-14/+0
Use UnaryOperator::CreateFNeg instead. Summary: With the introduction of the native fneg instruction, the fsub -0.0, %x idiom is obsolete. This patch makes LLVM emit fneg instead of the idiom in all places. Reviewed By: cameron.mcinally Differential Revision: https://reviews.llvm.org/D75130
2020-02-05Reapply: [SVE] Fix bug in simplification of scalable vector instructionsChristopher Tetreault1-0/+4
This reverts commit a05441038a3a4a011b9421751367c5c797d57137, reapplying commit 31574d38ac5fa4646cf01dd252a23e682402134f
2020-02-03Revert "[SVE] Fix bug in simplification of scalable vector instructions"Reid Kleckner1-4/+0
This reverts commit 31574d38ac5fa4646cf01dd252a23e682402134f. The newly added shufflevector test does not pass locally on either of my workstations.
2020-02-03[SVE] Fix bug in simplification of scalable vector instructionsChristopher Tetreault1-0/+4
Summary: * Most of the simplifications in SimplifyShuffleVectorInst depend on the concrete value of, or the length of the mask vector. For scalable vectors, this cannot be known at compile time. ** for these tests, detect if the vector is scalable before attempting the transformation * The functions ShuffleVectorInst::getMaskValue and ShuffleVectorInst::getShuffleMask access the value of the constant mask. However, since the length of the mask is unknown at compile time, these function do not work for scalable vectors. Add asserts to ensure that the input mask is not scalable Reviewers: efriedma, sdesmalen, apazos, chrisj, huihuiz Reviewed By: efriedma Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73555
2020-01-24[IR] Move CallBase::getOperandBundlesAsDefs out of line, NFCReid Kleckner1-0/+6
Copying operand bundles doesn't need to be inlined, and this template instantiation shows up in ClangBuildAnalyzer.
2019-12-17Resubmit "[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove"Guillaume Chatelet1-13/+5
Summary: This is a resubmit of D71473. This patch introduces a set of functions to enable deprecation of IRBuilder functions without breaking out of tree clients. Functions will be deprecated one by one and as in tree code is cleaned up. This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: aaron.ballman, courbet Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71547
2019-12-16Revert "[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove"Guillaume Chatelet1-5/+13
This reverts commit 181ab91efc9fb08dedda10a2fbc5fccb83ce8799.
2019-12-16[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMoveGuillaume Chatelet1-13/+5
Summary: This patch introduces a set of functions to enable deprecation of IRBuilder functions without breaking out of tree clients. Functions will be deprecated one by one and as in tree code is cleaned up. This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: arsenm, jvesely, nhaehnle, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71473
2019-11-12[IR] Redefine Freeze instructionaqjune1-3/+20
Summary: This patch redefines freeze instruction from being UnaryOperator to a subclass of UnaryInstruction. ConstantExpr freeze is removed, as discussed in the previous review. FreezeOperator is not added because there's no ConstantExpr freeze. `freeze i8* null` test is added to `test/Bindings/llvm-c/freeze.ll` as well, because the null pointer-related bug in `tools/llvm-c/echo.cpp` is now fixed. InstVisitor has visitFreeze now because freeze is not unaryop anymore. Reviewers: whitequark, deadalnix, craig.topper, jdoerfert, lebedev.ri Reviewed By: craig.topper, lebedev.ri Subscribers: regehr, nlopes, mehdi_amini, hiraditya, steven_wu, dexonsmith, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69932
2019-11-08[CostModel] Fixed isExtractSubvectorMask for undef index off endTim Renouf1-1/+1
ShuffleVectorInst::isExtractSubvectorMask, introduced in [CostModel] Add SK_ExtractSubvector handling to getInstructionThroughput (PR39368) erroneously thought that %340 = shufflevector <4 x float> %339, <4 x float> undef, <3 x i32> <i32 2, i32 3, i32 undef> is a subvector extract, even though it goes off the end of the parent vector with the undef index. That then caused an assert in BasicTTIImplBase::getExtractSubvectorOverhead. This commit fixes that, by not considering the above a subvector extract. Differential Revision: https://reviews.llvm.org/D70005 Change-Id: I87b8b00b24bef19ffc9a1b82ef4eca3b8a246eaf