[llvm] [TRE] Add tests for intrinsic accumulators (PR #74226)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 2 22:07:30 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 19bef888a8c7c58ddddbdf94d377fc485e050efb 549e0333e828100ec51a074ff577d75b2cbe1d66 -- llvm/include/llvm/IR/Constants.h llvm/include/llvm/IR/IntrinsicInst.h llvm/lib/IR/Constants.cpp llvm/lib/IR/Instruction.cpp llvm/lib/Transforms/Scalar/Reassociate.cpp llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index c3f0d98871..0b9f89830b 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1112,8 +1112,7 @@ public:
/// The identity constant C is defined as X op C = X and C op X = X where C
/// and X are the first two operands, and the operation is commutative.
static Constant *getIdentity(Instruction *I, Type *Ty,
- bool AllowRHSConstant = false,
- bool NSZ = false);
+ bool AllowRHSConstant = false, bool NSZ = false);
/// Return the absorbing element for the given binary
/// operation, i.e. a constant C such that X op C = C and C op X = C for
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 872e0a586f..a38b912164 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2559,26 +2559,26 @@ Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty,
Constant *ConstantExpr::getIntrinsicIdentity(Intrinsic::ID ID, Type *Ty) {
switch (ID) {
case Intrinsic::umax:
- return Constant::getNullValue(Ty);
+ return Constant::getNullValue(Ty);
case Intrinsic::umin:
- return Constant::getAllOnesValue(Ty);
+ return Constant::getAllOnesValue(Ty);
case Intrinsic::smax:
- return Constant::getIntegerValue(
- Ty, APInt::getSignedMinValue(Ty->getIntegerBitWidth()));
+ return Constant::getIntegerValue(
+ Ty, APInt::getSignedMinValue(Ty->getIntegerBitWidth()));
case Intrinsic::smin:
- return Constant::getIntegerValue(
- Ty, APInt::getSignedMaxValue(Ty->getIntegerBitWidth()));
+ return Constant::getIntegerValue(
+ Ty, APInt::getSignedMaxValue(Ty->getIntegerBitWidth()));
default:
- return nullptr;
+ return nullptr;
}
}
Constant *ConstantExpr::getIdentity(Instruction *I, Type *Ty,
bool AllowRHSConstant, bool NSZ) {
if (I->isBinaryOp())
- return getBinOpIdentity(I->getOpcode(), Ty, AllowRHSConstant, NSZ);
+ return getBinOpIdentity(I->getOpcode(), Ty, AllowRHSConstant, NSZ);
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
- return getIntrinsicIdentity(II->getIntrinsicID(), Ty);
+ return getIntrinsicIdentity(II->getIntrinsicID(), Ty);
return nullptr;
}
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
index a8464f5ee9..f031298d5e 100644
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -386,7 +386,6 @@ static bool canTransformAccumulatorRecursion(Instruction *I, CallInst *CI) {
"commutative operations must be either a binary or intrinsic op");
}
-
// Exactly one operand should be the result of the call instruction.
if ((LHS == CI && RHS == CI) || (LHS != CI && RHS != CI))
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/74226
More information about the llvm-commits
mailing list