-
Notifications
You must be signed in to change notification settings - Fork 14.3k
RISCV: Remove faulty assert that ignored subregister uses #141658
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
This was asserting the raw virtual register class was a scalar class, instead of computing the net result of the register class plus the subregister index on the operand. The machine verifier should be checking this was a valid combination in the first place, so just drop the assert.
@llvm/pr-subscribers-backend-risc-v Author: Matt Arsenault (arsenm) ChangesThis was asserting the raw virtual register class was a scalar Full diff: https://github.com/llvm/llvm-project/pull/141658.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
index f7cbfa1546de6..0bb81a58c29a4 100644
--- a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
+++ b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
@@ -1298,12 +1298,7 @@ RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
// Instructions like reductions may use a vector register as a scalar
// register. In this case, we should treat it as only reading the first lane.
if (isVectorOpUsedAsScalarOp(UserOp)) {
- [[maybe_unused]] Register R = UserOp.getReg();
- [[maybe_unused]] const TargetRegisterClass *RC = MRI->getRegClass(R);
- assert(RISCV::VRRegClass.hasSubClassEq(RC) &&
- "Expect LMUL 1 register class for vector as scalar operands!");
LLVM_DEBUG(dbgs() << " Used this operand as a scalar operand\n");
-
return MachineOperand::CreateImm(1);
}
diff --git a/llvm/test/CodeGen/RISCV/rvv/vl-optimizer-subreg-assert.mir b/llvm/test/CodeGen/RISCV/rvv/vl-optimizer-subreg-assert.mir
new file mode 100644
index 0000000000000..b816741285b43
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/vl-optimizer-subreg-assert.mir
@@ -0,0 +1,32 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# RUN: llc -mtriple=riscv64 -mattr=+v -run-pass=riscv-vl-optimizer -o - %s | FileCheck %s
+# Check that there is no assert on subregister uses.
+
+---
+name: vl_optimizer_subreg_assert
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $v8m2
+
+ ; CHECK-LABEL: name: vl_optimizer_subreg_assert
+ ; CHECK: liveins: $v8m2
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[DEF:%[0-9]+]]:vrm8 = IMPLICIT_DEF
+ ; CHECK-NEXT: [[DEF1:%[0-9]+]]:vmv0 = IMPLICIT_DEF
+ ; CHECK-NEXT: [[DEF2:%[0-9]+]]:vrm8 = IMPLICIT_DEF
+ ; CHECK-NEXT: [[PseudoVMERGE_VVM_M8_:%[0-9]+]]:vrm8nov0 = PseudoVMERGE_VVM_M8 $noreg, killed [[DEF2]], [[DEF]], [[DEF1]], -1, 6 /* e64 */
+ ; CHECK-NEXT: [[PseudoVREDMAXU_VS_M8_E64_:%[0-9]+]]:vr = PseudoVREDMAXU_VS_M8_E64 $noreg, [[PseudoVMERGE_VVM_M8_]], [[PseudoVMERGE_VVM_M8_]].sub_vrm1_0, -1, 6 /* e64 */, 1 /* ta, mu */
+ ; CHECK-NEXT: [[PseudoVMV_X_S:%[0-9]+]]:gpr = PseudoVMV_X_S killed [[PseudoVREDMAXU_VS_M8_E64_]], 6 /* e64 */
+ ; CHECK-NEXT: $x10 = COPY [[PseudoVMV_X_S]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:vrm8 = IMPLICIT_DEF
+ %1:vmv0 = IMPLICIT_DEF
+ %2:vrm8 = IMPLICIT_DEF
+ %3:vrm8nov0 = PseudoVMERGE_VVM_M8 $noreg, killed %2, %0, %1, -1, 6 /* e64 */
+ %4:vr = PseudoVREDMAXU_VS_M8_E64 $noreg, %3, %3.sub_vrm1_0, -1, 6 /* e64 */, 1 /* ta, mu */
+ %5:gpr = PseudoVMV_X_S killed %4, 6 /* e64 */
+ $x10 = COPY %5
+ PseudoRET implicit $x10
+
+...
|
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
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/19310 Here is the relevant piece of the build log for the reference
|
This was asserting the raw virtual register class was a scalar class, instead of computing the net result of the register class plus the subregister index on the operand. The machine verifier should be checking this was a valid combination in the first place, so just drop the assert.
This was asserting the raw virtual register class was a scalar
class, instead of computing the net result of the register class
plus the subregister index on the operand. The machine verifier
should be checking this was a valid combination in the first place,
so just drop the assert.