aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-10-23[ConstantFolding] Remove ConstantFoldLoadThroughGEPIndices() API (NFC)Nikita Popov1-13/+0
The last user of this API went away in 4f5e9a2bb28e1cf4a12c9330f52e664542400ec7.
2021-10-22[Loads] Use more powerful constant folding APINikita Popov1-3/+9
This follows up on D111023 by exporting the generic "load value from constant at given offset as given type" and using it in the store to load forwarding code. We now need to make sure that the load size is smaller than the store size, previously this was implicitly ensured by ConstantFoldLoadThroughBitcast(). Differential Revision: https://reviews.llvm.org/D112260
2021-10-16[ConstantFolding] ConstantFoldScalarCall2 - early-out if getLibFunc fails. NFC.Simon Pilgrim1-1/+3
2021-10-16[ConstantFolding] Use getValueAPF const ref value where possible. NFC.Simon Pilgrim1-3/+3
Don't copy the value if we can avoid it.
2021-10-16[ConstantFolding] ConstantFoldScalarCall1 - early-out if getLibFunc fails. NFC.Simon Pilgrim1-1/+3
2021-10-05[ConstantFold] Refactor load foldingNikita Popov1-134/+56
This refactors load folding to happen in two cleanly separated steps: ConstantFoldLoadFromConstPtr() takes a pointer to load from and decomposes it into a constant initializer base and an offset. Then ConstantFoldLoadFromConst() loads from that initializer at the given offset. This makes the core logic independent of having actual GEP expressions (and those GEP expressions having certain structure) and will allow exposing ConstantFoldLoadFromConst() as an independent API in the future. This is mostly only a refactoring, but it does make the folding logic slightly more powerful. Differential Revision: https://reviews.llvm.org/D111023
2021-10-04[APInt] Stop using soft-deprecated constructors and methods in llvm. NFC.Jay Foad1-5/+5
Stop using APInt constructors and methods that were soft-deprecated in D109483. This fixes all the uses I found in llvm, except for the APInt unit tests which should still test the deprecated methods. Differential Revision: https://reviews.llvm.org/D110807
2021-10-03[Analysis, CodeGen] Migrate from arg_operands to args (NFC)Kazu Hirata1-2/+2
Note that arg_operands is considered a legacy name. See llvm/include/llvm/IR/InstrTypes.h for details.
2021-09-28[ConstantFolding] Fold ptrtoint(gep i8 null, x) -> xAlex Richardson1-12/+22
I was looking at some missed optimizations in CHERI-enabled targets and noticed that we weren't removing vtable indirection for calls via known pointers-to-members. The underlying reason for this is that we represent pointers-to-function-members as {i8 addrspace(200)*, i64} and generate the constant offsets using (gep i8 null, <index>). We use a constant GEP here since inttoptr should be avoided for CHERI capabilities. The pointer-to-member call uses ptrtoint to extract the index, and due to this missing fold we can't infer the actual value loaded from the vtable. This is the initial constant folding change for this pattern, I will add an InstCombine fold as a follow-up. We could fold all inbounds GEP to null (and therefore the ptrtoint to zero) since zero is the only valid offset for an inbounds GEP. If the offset is not zero, that GEP is poison and therefore returning 0 is valid (https://alive2.llvm.org/ce/z/Gzb5iH). However, Clang currently generates inbounds GEPs on NULL for hand-written offsetof() expressions, so this could lead to miscompilations. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D110245
2021-09-20[IR] Add helper to convert offset to GEP indicesNikita Popov1-62/+24
We implement logic to convert a byte offset into a sequence of GEP indices for that offset in a number of places. This patch adds a DataLayout::getGEPIndicesForOffset() method, which implements the core logic. I've updated SROA, ConstantFolding and InstCombine to use it, and there's a few more places where it looks relevant. Differential Revision: https://reviews.llvm.org/D110043
2021-09-07[ConstFold] Support opaque pointers in constexpr GEPsNikita Popov1-2/+10
Support opaque pointers in SymbolicallyEvaluateGEP() by using the value type of a GlobalValue base or falling back to i8 if there isn't one. We don't unconditionally generate i8 GEPs here because that would lose inrange attribues, and because some optimizations on globals currently rely on GEP types (e.g. the globals SROA mentioned in the comment). Differential Revision: https://reviews.llvm.org/D109297
2021-09-02Revert @llvm.isnan intrinsic patchset.Roman Lebedev1-5/+1
Please refer to https://lists.llvm.org/pipermail/llvm-dev/2021-September/152440.html (and that whole thread.) TLDR: the original patch had no prior RFC, yet it had some changes that really need a proper RFC discussion. It won't be productive to discuss such an RFC, once it's actually posted, while said patch is already committed, because that introduces bias towards already-committed stuff, and the tree is potentially in broken state meanwhile. While the end result of discussion may lead back to the current design, it may also not lead to the current design. Therefore i take it upon myself to revert the tree back to last known good state. This reverts commit 4c4093e6e39fe6601f9c95a95a6bc242ef648cd5. This reverts commit 0a2b1ba33ae6dcaedb81417f7c4cc714f72a5968. This reverts commit d9873711cb03ac7aedcaadcba42f82c66e962e6e. This reverts commit 791006fb8c6fff4f33c33cb513a96b1d3f94c767. This reverts commit c22b64ef66f7518abb6f022fcdfd86d16c764caf. This reverts commit 72ebcd3198327da12804305bda13d9b7088772a8. This reverts commit 5fa6039a5fc1b6392a3c9a3326a76604e0cb1001. This reverts commit 9efda541bfbd145de90f7db38d935db6246dc45a. This reverts commit 94d3ff09cfa8d7aecf480e54da9a5334e262e76b.
2021-08-17[NFC] More get/removeAttribute() cleanupArthur Eubanks1-1/+1
2021-08-06Introduce intrinsic llvm.isnanSerge Pavlov1-1/+5
This is recommit of the patch 16ff91ebccda1128c43ff3cee104e2c603569fb2, reverted in 0c28a7c990c5218d6aec47c5052a51cba686ec5e because it had an error in call of getFastMathFlags (base type should be FPMathOperator but not Instruction). The original commit message is duplicated below: Clang has builtin function '__builtin_isnan', which implements C library function 'isnan'. This function now is implemented entirely in clang codegen, which expands the function into set of IR operations. There are three mechanisms by which the expansion can be made. * The most common mechanism is using an unordered comparison made by instruction 'fcmp uno'. This simple solution is target-independent and works well in most cases. It however is not suitable if floating point exceptions are tracked. Corresponding IEEE 754 operation and C function must never raise FP exception, even if the argument is a signaling NaN. Compare instructions usually does not have such property, they raise 'invalid' exception in such case. So this mechanism is unsuitable when exception behavior is strict. In particular it could result in unexpected trapping if argument is SNaN. * Another solution was implemented in https://reviews.llvm.org/D95948. It is used in the cases when raising FP exceptions by 'isnan' is not allowed. This solution implements 'isnan' using integer operations. It solves the problem of exceptions, but offers one solution for all targets, however some can do the check in more efficient way. * Solution implemented by https://reviews.llvm.org/D96568 introduced a hook 'clang::TargetCodeGenInfo::testFPKind', which injects target specific code into IR. Now only SystemZ implements this hook and it generates a call to target specific intrinsic function. Although these mechanisms allow to implement 'isnan' with enough efficiency, expanding 'isnan' in clang has drawbacks: * The operation 'isnan' is hidden behind generic integer operations or target-specific intrinsics. It complicates analysis and can prevent some optimizations. * IR can be created by tools other than clang, in this case treatment of 'isnan' has to be duplicated in that tool. Another issue with the current implementation of 'isnan' comes from the use of options '-ffast-math' or '-fno-honor-nans'. If such option is specified, 'fcmp uno' may be optimized to 'false'. It is valid optimization in general, but it results in 'isnan' always returning 'false'. For example, in some libc++ implementations the following code returns 'false': std::isnan(std::numeric_limits<float>::quiet_NaN()) The options '-ffast-math' and '-fno-honor-nans' imply that FP operation operands are never NaNs. This assumption however should not be applied to the functions that check FP number properties, including 'isnan'. If such function returns expected result instead of actually making checks, it becomes useless in many cases. The option '-ffast-math' is often used for performance critical code, as it can speed up execution by the expense of manual treatment of corner cases. If 'isnan' returns assumed result, a user cannot use it in the manual treatment of NaNs and has to invent replacements, like making the check using integer operations. There is a discussion in https://reviews.llvm.org/D18513#387418, which also expresses the opinion, that limitations imposed by '-ffast-math' should be applied only to 'math' functions but not to 'tests'. To overcome these drawbacks, this change introduces a new IR intrinsic function 'llvm.isnan', which realizes the check as specified by IEEE-754 and C standards in target-agnostic way. During IR transformations it does not undergo undesirable optimizations. It reaches instruction selection, where is lowered in target-dependent way. The lowering can vary depending on options like '-ffast-math' or '-ffp-model' so the resulting code satisfies requested semantics. Differential Revision: https://reviews.llvm.org/D104854
2021-08-04Revert "Introduce intrinsic llvm.isnan"Serge Pavlov1-5/+1
This reverts commit 16ff91ebccda1128c43ff3cee104e2c603569fb2. Several errors were reported mainly test-suite execution time. Reverted for investigation.
2021-08-04Introduce intrinsic llvm.isnanSerge Pavlov1-1/+5
Clang has builtin function '__builtin_isnan', which implements C library function 'isnan'. This function now is implemented entirely in clang codegen, which expands the function into set of IR operations. There are three mechanisms by which the expansion can be made. * The most common mechanism is using an unordered comparison made by instruction 'fcmp uno'. This simple solution is target-independent and works well in most cases. It however is not suitable if floating point exceptions are tracked. Corresponding IEEE 754 operation and C function must never raise FP exception, even if the argument is a signaling NaN. Compare instructions usually does not have such property, they raise 'invalid' exception in such case. So this mechanism is unsuitable when exception behavior is strict. In particular it could result in unexpected trapping if argument is SNaN. * Another solution was implemented in https://reviews.llvm.org/D95948. It is used in the cases when raising FP exceptions by 'isnan' is not allowed. This solution implements 'isnan' using integer operations. It solves the problem of exceptions, but offers one solution for all targets, however some can do the check in more efficient way. * Solution implemented by https://reviews.llvm.org/D96568 introduced a hook 'clang::TargetCodeGenInfo::testFPKind', which injects target specific code into IR. Now only SystemZ implements this hook and it generates a call to target specific intrinsic function. Although these mechanisms allow to implement 'isnan' with enough efficiency, expanding 'isnan' in clang has drawbacks: * The operation 'isnan' is hidden behind generic integer operations or target-specific intrinsics. It complicates analysis and can prevent some optimizations. * IR can be created by tools other than clang, in this case treatment of 'isnan' has to be duplicated in that tool. Another issue with the current implementation of 'isnan' comes from the use of options '-ffast-math' or '-fno-honor-nans'. If such option is specified, 'fcmp uno' may be optimized to 'false'. It is valid optimization in general, but it results in 'isnan' always returning 'false'. For example, in some libc++ implementations the following code returns 'false': std::isnan(std::numeric_limits<float>::quiet_NaN()) The options '-ffast-math' and '-fno-honor-nans' imply that FP operation operands are never NaNs. This assumption however should not be applied to the functions that check FP number properties, including 'isnan'. If such function returns expected result instead of actually making checks, it becomes useless in many cases. The option '-ffast-math' is often used for performance critical code, as it can speed up execution by the expense of manual treatment of corner cases. If 'isnan' returns assumed result, a user cannot use it in the manual treatment of NaNs and has to invent replacements, like making the check using integer operations. There is a discussion in https://reviews.llvm.org/D18513#387418, which also expresses the opinion, that limitations imposed by '-ffast-math' should be applied only to 'math' functions but not to 'tests'. To overcome these drawbacks, this change introduces a new IR intrinsic function 'llvm.isnan', which realizes the check as specified by IEEE-754 and C standards in target-agnostic way. During IR transformations it does not undergo undesirable optimizations. It reaches instruction selection, where is lowered in target-dependent way. The lowering can vary depending on options like '-ffast-math' or '-ffp-model' so the resulting code satisfies requested semantics. Differential Revision: https://reviews.llvm.org/D104854
2021-07-23[ConstantFolding] Fold constrained arithmetic intrinsicsSerge Pavlov1-2/+109
Constfold constrained variants of operations fadd, fsub, fmul, fdiv, frem, fma and fmuladd. The change also sets up some means to support for removal of unused constrained intrinsics. They are declared as accessing memory to model interaction with floating point environment, so they were not removed, as they have side effect. Now constrained intrinsics that have "fpexcept.ignore" as exception behavior are removed if they have no uses. As for intrinsics that have exception behavior other than "fpexcept.ignore", they can be removed if it is known that they do not raise floating point exceptions. It happens when doing constant folding, attributes of such intrinsic are changed so that the intrinsic is not claimed as accessing memory. Differential Revision: https://reviews.llvm.org/D102673
2021-07-20[ConstantFolding] avoid crashing on a fake math library callSanjay Patel1-2/+13
https://llvm.org/PR50960
2021-06-22[ConstantFold] Delay fetching pointer element typeNikita Popov1-8/+6
Don't do this while stipping pointer casts, instead fetch it at the end. This improves compatibility with opaque pointers for the case where the base object is not opaque.
2021-06-22[ConstantFolding] Separate conditions in GEP evaluation (NFC)Nikita Popov1-20/+17
Handle to gep p, 0-v case separately, and not as part of the loop that ensures all indices are constant integers. Those two things are not really related.
2021-06-10[ConstantFolding] Enable folding of min/max/copysign for all floatsSerge Pavlov1-3/+11
Previously such folding was enabled for half, float and double values only. With this change it is allowed for other floating point values also. Differential Revision: https://reviews.llvm.org/D103956
2021-06-01[OpaquePtr] Create API to make a copy of a PointerType with some address spaceArthur Eubanks1-2/+3
Some existing places use getPointerElementType() to create a copy of a pointer type with some new address space. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D103429
2021-05-28[ConstantFolding] Fix -Wunused-variable warning (NFC)Yang Fan1-1/+1
GCC warning: ``` /llvm-project/llvm/lib/Analysis/ConstantFolding.cpp: In function ‘llvm::Constant* llvm::ConstantFoldLoadFromConstPtr(llvm::Constant*, llvm::Type*, const llvm::DataLayout&)’: /llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:713:19: warning: unused variable ‘SimplifiedGEP’ [-Wunused-variable] 713 | if (auto *SimplifiedGEP = dyn_cast<GEPOperator>(Simplified)) { | ^~~~~~~~~~~~~ ```
2021-05-27[ConstFold] Simplify a load's GEP operand through local aliasesArthur Eubanks1-5/+47
MSVC-style RTTI produces loads through a GEP of a local alias which itself is a GEP. Currently we aren't able to devirtualize any virtual calls when MSVC RTTI is enabled. This patch attempts to simplify a load's GEP operand by calling SymbolicallyEvaluateGEP() with an option to look through local aliases. Differential Revision: https://reviews.llvm.org/D101100
2021-05-24[ConstProp] propagate poison from vector reduction element(s) to resultSanjay Patel1-1/+1
This follows from the underlying logic for binops and min/max. Although it does not appear that we handle this for min/max intrinsics currently. https://alive2.llvm.org/ce/z/Kq9Xnh
2021-05-22[ConstantFolding] Use APFloat for constant folding. NFCSerge Pavlov1-103/+80
Replace use of host floating types with operations on APFloat when it is possible. Use of APFloat makes analysis more convenient and facilitates constant folding in the case of non-default FP environment. Differential Revision: https://reviews.llvm.org/D102672
2021-05-21[APFloat] convertToDouble/Float can work on shorter typesSerge Pavlov1-4/+1
Previously APFloat::convertToDouble may be called only for APFloats that were built using double semantics. Other semantics like single precision were not allowed although corresponding numbers could be converted to double without loss of precision. The similar restriction applied to APFloat::convertToFloat. With this change any APFloat that can be precisely represented by double can be handled with convertToDouble. Behavior of convertToFloat was updated similarly. It make the conversion operations more convenient and adds support for formats like half and bfloat. Differential Revision: https://reviews.llvm.org/D102671
2021-05-14[LowerConstantIntrinsics] reuse isManifestLogic from ConstantFoldingNick Desaulniers1-14/+1
GlobalVariables are Constants, yet should not unconditionally be considered true for __builtin_constant_p. Via the LangRef https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic: This intrinsic generates no code. If its argument is known to be a manifest compile-time constant value, then the intrinsic will be converted to a constant true value. Otherwise, it will be converted to a constant false value. In particular, note that if the argument is a constant expression which refers to a global (the address of which _is_ a constant, but not manifest during the compile), then the intrinsic evaluates to false. Move isManifestConstant from ConstantFolding to be a method of Constant so that we can reuse the same logic in LowerConstantIntrinsics. pr/41459 Reviewed By: rsmith, george.burgess.iv Differential Revision: https://reviews.llvm.org/D102367
2021-05-10[AMDGPU] Constant fold Intrinsic::amdgcn_permStanislav Mekhanoshin1-0/+44
Differential Revision: https://reviews.llvm.org/D102203
2021-04-29[ConstantFolding] propagate poison through vector reduction intrinsicsSanjay Patel1-1/+5
2021-04-29[ConstantFolding] refactor helper for vector reductions; NFCSanjay Patel1-33/+31
We should handle other cases (undef/poison), so reduce the duplication of repeated switches.
2021-04-27[ConstFold] Use const-folded operands in more placesArthur Eubanks1-22/+9
Previously we were const folding operands but not passing them. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D101394
2021-04-20[AArch64] Constant fold sve_convert_from_svbool(zero) to zeroJoe Ellis1-17/+33
Co-authored-by: Paul Walker <paul.walker@arm.com> Differential Revision: https://reviews.llvm.org/D100463
2021-04-20Explicitly pass type to cast load constant folding resultArthur Eubanks1-13/+9
Previously we would use the type of the pointee to determine what to cast the result of constant folding a load. To aid with opaque pointer types, we should explicitly pass the type of the load rather than looking at pointee types. ConstantFoldLoadThroughBitcast() converts the const prop'd value to the proper load type (e.g. [1 x i32] -> i32). Instead of calling this in every intermediate step like bitcasts, we only call this when we actually see the global initializer value. In some existing uses of this API, we don't know the exact type we're loading from immediately (e.g. first we visit a bitcast, then we visit the load using the bitcast). In those cases we have to manually call ConstantFoldLoadThroughBitcast() when simplifying the load to make sure that we cast to the proper type. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D100718
2021-04-16[WebAssembly] Remove saturating fp-to-int target intrinsicsThomas Lively1-20/+4
Use the target-independent @llvm.fptosi and @llvm.fptoui intrinsics instead. This includes removing the instrinsics for i32x4.trunc_sat_zero_f64x2_{s,u}, which are now represented in IR as a saturating truncation to a v2i32 followed by a concatenation with a zero vector. Differential Revision: https://reviews.llvm.org/D100596
2021-03-31[ConstantFolding] Fixing addo/subo with undefGeorge Mitenkov1-5/+8
When folding addo/subo with undef, the current convention is to use { -1, false } for addo and { 0, false } for subo. This was fixed for InstSimplify in https://reviews.llvm.org/rGf094d65beaa492e845b03561eddd75b5be653a01, but not in ConstantFolding. Reviewed By: nikic, lebedev.ri Differential Revision: https://reviews.llvm.org/D99564
2021-03-21Reapply [ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()Nikita Popov1-1/+1
There seems to be an impedance mismatch between what the type system considers an aggregate (structs and arrays) and what constants consider an aggregate (structs, arrays and vectors). Adjust the type check to consider vectors as well. The previous version of the patch dropped the type check entirely, but it turns out that getAggregateElement() does require the constant to be an aggregate in some edge cases: For Poison/Undef the getNumElements() API is called, without checking in advance that we're dealing with an aggregate. Possibly the implementation should avoid doing that, but for now I'm adding an assert so the next person doesn't fall into this trap.
2021-03-16Revert "[ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()"Zequan Wu1-0/+5
That commit caused chromium build to crash: https://bugs.chromium.org/p/chromium/issues/detail?id=1188885 This reverts commit edf7004851519464f86b0f641da4d6c9506decb1.
2021-03-12[ConstantFold] Handle undef/poison when constant folding smul_fix/smul_fix_satBjorn Pettersson1-35/+36
Do constant folding according to posion * C -> poison C * poison -> poison undef * C -> 0 C * undef -> 0 for smul_fix and smul_fix_sat intrinsics (for any scale). Reviewed By: nikic, aqjune, nagisa Differential Revision: https://reviews.llvm.org/D98410
2021-03-06[ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()Nikita Popov1-5/+0
There seems to be an impedance mismatch between what the type system considers an aggregate (structs and arrays) and what constants consider an aggregate (structs, arrays and vectors). Rather than adjusting the type check, simply drop it entirely, as getAggregateElement() is well-defined for non-aggregates: It simply returns null in that case.
2021-01-10[ConstantFold] Fold fptoi.sat intrinsicsNikita Popov1-1/+16
The APFloat::convertToInteger() API already implements the desired saturation semantics.
2021-01-08[ConstProp] Constant propagation for get.active.lane.mask instrinsicsDavid Green1-0/+20
Similar to the Arm VCTP intrinsics, if the operands of an active.lane.mask are both known, the constant lane mask can be calculated. This can come up after unrolling the loops. Differential Revision: https://reviews.llvm.org/D94103
2020-12-30[X86] Add x86_amx type for intel AMX.Luo, Yuanke1-6/+9
The x86_amx is used for AMX intrisics. <256 x i32> is bitcast to x86_amx when it is used by AMX intrinsics, and x86_amx is bitcast to <256 x i32> when it is used by load/store instruction. So amx intrinsics only operate on type x86_amx. It can help to separate amx intrinsics from llvm IR instructions (+-*/). Thank Craig for the idea. This patch depend on https://reviews.llvm.org/D87981. Differential Revision: https://reviews.llvm.org/D91927
2020-11-19[llvm][IR] Add dso_local_equivalent ConstantLeonard Chan1-3/+18
The `dso_local_equivalent` constant is a wrapper for functions that represents a value which is functionally equivalent to the global passed to this. That is, if this accepts a function, calling this constant should have the same effects as calling the function directly. This could be a direct reference to the function, the `@plt` modifier on X86/AArch64, a thunk, or anything that's equivalent to the resolved function as a call target. When lowered, the returned address must have a constant offset at link time from some other symbol defined within the same binary. The address of this value is also insignificant. The name is leveraged from `dso_local` where use of a function or variable is resolved to a symbol in the same linkage unit. In this patch: - Addition of `dso_local_equivalent` and handling it - Update Constant::needsRelocation() to strip constant inbound GEPs and take advantage of `dso_local_equivalent` for relative references This is useful for the [Relative VTables C++ ABI](https://reviews.llvm.org/D72959) which makes vtables readonly. This works by replacing the dynamic relocations for function pointers in them with static relocations that represent the offset between the vtable and virtual functions. If a function is externally defined, `dso_local_equivalent` can be used as a generic wrapper for the function to still allow for this static offset calculation to be done. See [RFC](http://lists.llvm.org/pipermail/llvm-dev/2020-August/144469.html) for more details. Differential Revision: https://reviews.llvm.org/D77248
2020-10-16[AMDGPU] Add new llvm.amdgcn.fma.legacy intrinsicJay Foad1-2/+16
Differential Revision: https://reviews.llvm.org/D89558
2020-10-07[llvm][mlir] Promote the experimental reduction intrinsics to be first class ↵Amara Emerson1-36/+36
intrinsics. This change renames the intrinsics to not have "experimental" in the name. The autoupgrader will handle legacy intrinsics. Relevant ML thread: http://lists.llvm.org/pipermail/llvm-dev/2020-April/140729.html Differential Revision: https://reviews.llvm.org/D88787
2020-09-19[ConstantFolding] add undef handling for fmin/fmax intrinsicsSanjay Patel1-0/+19
The output here may not be optimal (yet), but it should be consistent for commuted operands (it was not before) and correct. We can do better by checking FMF and NaN if needed. Code in InstSimplify generally assumes that we have already folded code like this, so it was not handling 2 constant inputs by commuting consistently.
2020-08-10[WebAssembly][ConstantFolding] Fold fp-to-int truncation intrinsicsThomas Lively1-1/+42
Constant fold both the trapping and saturating versions of the WebAssembly truncation intrinsics. The tests are adapted from the WebAssembly spec tests for the corresponding instructions. Requested in PR46982. Differential Revision: https://reviews.llvm.org/D85392
2020-07-31[ConstantFolding] fold abs intrinsicSanjay Patel1-0/+13
The handling for minimum value is similar to cttz/ctlz with 0 just above this case. Differential Revision: https://reviews.llvm.org/D84942
2020-07-31[NFC] Remove unused GetUnderlyingObject paramenterVitaly Buka1-1/+1
Depends on D84617. Differential Revision: https://reviews.llvm.org/D84621