[clang] 904a79f - [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility
via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 25 22:57:56 PST 2022
Author: eopXD
Date: 2022-12-25T22:57:51-08:00
New Revision: 904a79f99153d9d8ed67beeed82a0f910bb000fd
URL: https://github.com/llvm/llvm-project/commit/904a79f99153d9d8ed67beeed82a0f910bb000fd
DIFF: https://github.com/llvm/llvm-project/commit/904a79f99153d9d8ed67beeed82a0f910bb000fd.diff
LOG: [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility
As topic, this commit reduces the for-loops with utilities of SmallVector.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D140661
Added:
Modified:
clang/include/clang/Basic/riscv_vector.td
clang/lib/Support/RISCVVIntrinsicUtils.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td
index 7dbd331b2c5ec..1ed8e00dd82ba 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -848,8 +848,7 @@ multiclass RVVUnitStridedSegLoad<string op> {
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
// intrinsic: (maskedoff0, ..., ptr, mask, vl)
if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 2]);
@@ -867,8 +866,7 @@ multiclass RVVUnitStridedSegLoad<string op> {
// TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
// intrinsic: (passthru0, passthru1, ..., ptr, vl)
if (DefaultPolicy == TAIL_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 1]);
} else {
@@ -927,8 +925,7 @@ multiclass RVVUnitStridedSegLoadFF<string op> {
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
// intrinsic: (maskedoff0, ..., ptr, mask, vl)
if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 3]);
@@ -948,8 +945,7 @@ multiclass RVVUnitStridedSegLoadFF<string op> {
// TU builtin: (val0 address, ..., passthru0, ..., ptr, new_vl, vl)
// intrinsic: (passthru0, passthru1, ..., ptr, vl)
if (DefaultPolicy == TAIL_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 2]);
NewVL = Ops[NF + 1];
@@ -1010,8 +1006,7 @@ multiclass RVVStridedSegLoad<string op> {
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl)
// intrinsic: (maskedoff0, ..., ptr, stride, mask, vl)
if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF + 2]);
Operands.push_back(Ops[NF]);
@@ -1031,8 +1026,7 @@ multiclass RVVStridedSegLoad<string op> {
// TU builtin: (val0 address, ..., passthru0, ..., ptr, stride, vl)
// intrinsic: (passthru0, passthru1, ..., ptr, stride, vl)
if (DefaultPolicy == TAIL_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF + 2]);
@@ -1086,8 +1080,7 @@ multiclass RVVIndexedSegLoad<string op> {
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl)
// intrinsic: (maskedoff0, ..., ptr, index, mask, vl)
if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF + 2]);
Operands.push_back(Ops[NF]);
@@ -1109,8 +1102,7 @@ multiclass RVVIndexedSegLoad<string op> {
// TU builtin: (val0 address, ..., passthru0, ..., ptr, index, vl)
// intrinsic: (passthru0, passthru1, ..., ptr, index, vl)
if (DefaultPolicy == TAIL_AGNOSTIC) {
- for (unsigned I = 0; I < NF; ++I)
- Operands.push_back(llvm::PoisonValue::get(ResultType));
+ Operands.append(NF, llvm::PoisonValue::get(ResultType));
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[NF + 1]);
Operands.push_back(Ops[NF + 2]);
diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index d9feec85b78c7..bd05dadb48c3c 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -939,8 +939,7 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
// (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...)
PrototypeDescriptor MaskoffType = NewPrototype[1];
MaskoffType.TM &= ~static_cast<uint8_t>(TypeModifier::Pointer);
- for (unsigned I = 0; I < NF; ++I)
- NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+ NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
}
}
// Erase passthru operand for TAM
@@ -983,8 +982,7 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
// (void, op0 address, op1 address, maskedoff0, maskedoff1, ...)
PrototypeDescriptor MaskoffType = Prototype[1];
MaskoffType.TM &= ~static_cast<uint8_t>(TypeModifier::Pointer);
- for (unsigned I = 0; I < NF; ++I)
- NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+ NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
}
}
More information about the cfe-commits
mailing list