[llvm] 3fc4b58 - [RISCV] Make SplatOperand start from 0.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 17 20:30:06 PST 2022
Author: Han-Kuan Chen
Date: 2022-01-17T20:14:59-08:00
New Revision: 3fc4b5896a336b5b74c52bbde992992aeb5a78f0
URL: https://github.com/llvm/llvm-project/commit/3fc4b5896a336b5b74c52bbde992992aeb5a78f0
DIFF: https://github.com/llvm/llvm-project/commit/3fc4b5896a336b5b74c52bbde992992aeb5a78f0.diff
LOG: [RISCV] Make SplatOperand start from 0.
Current SplatOperand starts from 1 because operand 0 (or 1) is intrinsic
id in SelectionDAG.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D117453
Added:
Modified:
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index a3b4388a7aabc..56e3b353a4947 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -120,12 +120,14 @@ let TargetPrefix = "riscv" in {
//===----------------------------------------------------------------------===//
// Vectors
+// The intrinsic does not have any operand that must be extended.
+defvar NoSplatOperand = 0xF;
+
class RISCVVIntrinsic {
// These intrinsics may accept illegal integer values in their llvm_any_ty
- // operand, so they have to be extended. If set to zero then the intrinsic
- // does not have any operand that must be extended.
+ // operand, so they have to be extended.
Intrinsic IntrinsicID = !cast<Intrinsic>(NAME);
- bits<4> SplatOperand = 0;
+ bits<4> SplatOperand = NoSplatOperand;
}
let TargetPrefix = "riscv" in {
@@ -344,7 +346,7 @@ let TargetPrefix = "riscv" in {
: Intrinsic<[llvm_anyvector_ty],
[LLVMMatchType<0>, llvm_any_ty, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For destination vector type is the same as first source vector (with mask).
// Input: (maskedoff, vector_in, vector_in/scalar_in, mask, vl, ta)
@@ -354,7 +356,7 @@ let TargetPrefix = "riscv" in {
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty,
LLVMMatchType<2>],
[ImmArg<ArgIndex<5>>, IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 3;
+ let SplatOperand = 2;
}
// For destination vector type is the same as first source vector. The
// second source operand must match the destination type or be an XLen scalar.
@@ -378,7 +380,7 @@ let TargetPrefix = "riscv" in {
: Intrinsic<[llvm_anyvector_ty],
[llvm_anyvector_ty, llvm_any_ty, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For destination vector type is NOT the same as first source vector (with mask).
// Input: (maskedoff, vector_in, vector_in/scalar_in, mask, vl, ta)
@@ -388,7 +390,7 @@ let TargetPrefix = "riscv" in {
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty,
LLVMMatchType<3>],
[ImmArg<ArgIndex<5>>, IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 3;
+ let SplatOperand = 2;
}
// For destination vector type is NOT the same as first source vector. The
// second source operand must match the destination type or be an XLen scalar.
@@ -414,7 +416,7 @@ let TargetPrefix = "riscv" in {
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For binary operations with mask type output and V0 as input.
// Output: (mask type output)
@@ -425,7 +427,7 @@ let TargetPrefix = "riscv" in {
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For binary operations with mask type output.
// Output: (mask type output)
@@ -434,7 +436,7 @@ let TargetPrefix = "riscv" in {
: Intrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
[llvm_anyvector_ty, llvm_any_ty, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For binary operations with mask type output without mask.
// Output: (mask type output)
@@ -443,7 +445,7 @@ let TargetPrefix = "riscv" in {
: Intrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
[llvm_anyvector_ty, llvm_any_ty, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For binary operations with mask type output with mask.
// Output: (mask type output)
@@ -454,7 +456,7 @@ let TargetPrefix = "riscv" in {
llvm_anyvector_ty, llvm_any_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 3;
+ let SplatOperand = 2;
}
// For FP classify operations.
// Output: (bit mask type output)
@@ -478,7 +480,7 @@ let TargetPrefix = "riscv" in {
: Intrinsic<[llvm_anyvector_ty],
[LLVMMatchType<0>, llvm_any_ty, llvm_anyint_ty],
[IntrNoMem, IntrHasSideEffects]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For Saturating binary operations with mask.
// The destination vector type is the same as first source vector.
@@ -489,7 +491,7 @@ let TargetPrefix = "riscv" in {
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty,
LLVMMatchType<2>],
[ImmArg<ArgIndex<5>>, IntrNoMem, IntrHasSideEffects]>, RISCVVIntrinsic {
- let SplatOperand = 3;
+ let SplatOperand = 2;
}
// For Saturating binary operations.
// The destination vector type is the same as first source vector.
@@ -542,28 +544,28 @@ let TargetPrefix = "riscv" in {
[LLVMMatchType<0>, llvm_any_ty, LLVMMatchType<0>,
llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
class RISCVTernaryAAXAMask
: Intrinsic<[llvm_anyvector_ty],
[LLVMMatchType<0>, llvm_any_ty, LLVMMatchType<0>,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
class RISCVTernaryWideNoMask
: Intrinsic< [llvm_anyvector_ty],
[LLVMMatchType<0>, llvm_any_ty, llvm_anyvector_ty,
llvm_anyint_ty],
[IntrNoMem] >, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
class RISCVTernaryWideMask
: Intrinsic< [llvm_anyvector_ty],
[LLVMMatchType<0>, llvm_any_ty, llvm_anyvector_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_anyint_ty],
[IntrNoMem]>, RISCVVIntrinsic {
- let SplatOperand = 2;
+ let SplatOperand = 1;
}
// For Reduction ternary operations.
// For destination vector type is the same as first and third source vector.
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 509e1e9b82764..ef6ee665b43fa 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -4151,10 +4151,10 @@ static SDValue lowerVectorIntrinsicSplats(SDValue Op, SelectionDAG &DAG,
const RISCVVIntrinsicsTable::RISCVVIntrinsicInfo *II =
RISCVVIntrinsicsTable::getRISCVVIntrinsicInfo(IntNo);
- if (!II || !II->SplatOperand)
+ if (!II || !II->hasSplatOperand())
return SDValue();
- unsigned SplatOp = II->SplatOperand + HasChain;
+ unsigned SplatOp = II->SplatOperand + 1 + HasChain;
assert(SplatOp < Op.getNumOperands());
SmallVector<SDValue, 8> Operands(Op->op_begin(), Op->op_end());
@@ -4184,7 +4184,7 @@ static SDValue lowerVectorIntrinsicSplats(SDValue Op, SelectionDAG &DAG,
// that a widening operation never uses SEW=64.
// NOTE: If this fails the below assert, we can probably just find the
// element count from any operand or result and use it to construct the VT.
- assert(II->SplatOperand > 1 && "Unexpected splat operand!");
+ assert(II->SplatOperand > 0 && "Unexpected splat operand!");
MVT VT = Op.getOperand(SplatOp - 1).getSimpleValueType();
// The more complex case is when the scalar is larger than XLenVT.
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index b8ff9522bd062..7b3ce7f9fd615 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -670,6 +670,10 @@ namespace RISCVVIntrinsicsTable {
struct RISCVVIntrinsicInfo {
unsigned IntrinsicID;
uint8_t SplatOperand;
+ bool hasSplatOperand() const {
+ // 0xF is not valid. See NoSplatOperand in IntrinsicsRISCV.td.
+ return SplatOperand != 0xF;
+ }
};
using namespace RISCV;
More information about the llvm-commits
mailing list