-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV][NFC] Use NFList in NFSet #67517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These two subroutines are almost the same except the LMUL encoding. We can use `NFList` in `NFSet` to remove duplicated code.
@llvm/pr-subscribers-backend-risc-v ChangesThese two subroutines are almost the same except the LMUL encoding. We can use Full diff: https://github.com/llvm/llvm-project/pull/67517.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 0c76e36daf72033..e0d75ef77b76a53 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -219,10 +219,8 @@ defvar FPListW = [SCALAR_F16, SCALAR_F32];
defvar BFPListW = [SCALAR_BF16];
class NFSet<LMULInfo m> {
- list<int> L = !cond(!eq(m.value, V_M8.value): [],
- !eq(m.value, V_M4.value): [2],
- !eq(m.value, V_M2.value): [2, 3, 4],
- true: [2, 3, 4, 5, 6, 7, 8]);
+ defvar lmul = !shl(1, m.value);
+ list<int> L = NFList<lmul>.L;
}
class octuple_to_str<int octuple> {
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 1a6145f92908134..ab0d354967b34c7 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -337,14 +337,15 @@ defvar LMULList = [1, 2, 4, 8];
// Utility classes for segment load/store.
//===----------------------------------------------------------------------===//
// The set of legal NF for LMUL = lmul.
-// LMUL == 1, NF = 2, 3, 4, 5, 6, 7, 8
+// LMUL <= 1, NF = 2, 3, 4, 5, 6, 7, 8
// LMUL == 2, NF = 2, 3, 4
// LMUL == 4, NF = 2
+// LMUL == 8, no legal NF
class NFList<int lmul> {
- list<int> L = !cond(!eq(lmul, 1): [2, 3, 4, 5, 6, 7, 8],
- !eq(lmul, 2): [2, 3, 4],
+ list<int> L = !cond(!eq(lmul, 8): [],
!eq(lmul, 4): [2],
- !eq(lmul, 8): []);
+ !eq(lmul, 2): [2, 3, 4],
+ true: [2, 3, 4, 5, 6, 7, 8]);
}
// Generate [start, end) SubRegIndex list.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
!eq(m.value, V_M4.value): [2], | ||
!eq(m.value, V_M2.value): [2, 3, 4], | ||
true: [2, 3, 4, 5, 6, 7, 8]); | ||
defvar lmul = !shl(1, m.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the fractional LMULs, this encoding gives:
>>> 1 << 0b101
32
>>> 1 << 0b110
64
>>> 1 << 0b111
128
NFList
was never used with fractional LMUL in the past. This encoding ends up working out since fractional LMUL will hit the true branch of NFList
, but it does diverge from RISCVII::VLMUL
encoding which caught my eye. I wanted to say something so we're aware of it, but I am not requesting a change since I think it is fine as this is an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think fractional will just take on 0b000 since it’s a 3 bit value. Still fine with me.
Edit: sorry it’s not a 3 bit value I take that back. Please Ignore this comment.
These two subroutines are almost the same except the LMUL encoding. We can use `NFList` in `NFSet` to remove duplicated code.
These two subroutines are almost the same except the LMUL encoding.
We can use
NFList
inNFSet
to remove duplicated code.