[llvm] b5b17bf - [RISCV] Fix assertion failure in `genShXAddAddShift` (#88757)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 10:50:26 PDT 2024
Author: Yingwei Zheng
Date: 2024-04-16T01:50:22+08:00
New Revision: b5b17bf613010b5ea900d2981365b9d2c846a20f
URL: https://github.com/llvm/llvm-project/commit/b5b17bf613010b5ea900d2981365b9d2c846a20f
DIFF: https://github.com/llvm/llvm-project/commit/b5b17bf613010b5ea900d2981365b9d2c846a20f.diff
LOG: [RISCV] Fix assertion failure in `genShXAddAddShift` (#88757)
Fix assertion failure in our downstream CI
https://github.com/dtcxzyw/llvm-codegen-benchmark/issues/1.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/test/CodeGen/RISCV/rv64zba.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 508f607fab20fd..b0fda040519a57 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -1986,7 +1986,7 @@ genShXAddAddShift(MachineInstr &Root, unsigned AddOpIdx,
MRI.getUniqueVRegDef(AddMI->getOperand(AddOpIdx).getReg());
unsigned InnerShiftAmt = ShiftMI->getOperand(2).getImm();
- assert(InnerShiftAmt > OuterShiftAmt && "Unexpected shift amount");
+ assert(InnerShiftAmt >= OuterShiftAmt && "Unexpected shift amount");
unsigned InnerOpc;
switch (InnerShiftAmt - OuterShiftAmt) {
diff --git a/llvm/test/CodeGen/RISCV/rv64zba.ll b/llvm/test/CodeGen/RISCV/rv64zba.ll
index 067addc819f7e6..bb4be323ecb2e5 100644
--- a/llvm/test/CodeGen/RISCV/rv64zba.ll
+++ b/llvm/test/CodeGen/RISCV/rv64zba.ll
@@ -2389,3 +2389,26 @@ define i64 @array_index_sh4_sh3(ptr %p, i64 %idx1, i64 %idx2) {
%b = load i64, ptr %a, align 8
ret i64 %b
}
+
+define ptr @test_gep_gep_dont_crash(ptr %p, i64 %a1, i64 %a2) {
+; RV64I-LABEL: test_gep_gep_dont_crash:
+; RV64I: # %bb.0:
+; RV64I-NEXT: srliw a2, a2, 6
+; RV64I-NEXT: slli a2, a2, 3
+; RV64I-NEXT: slli a1, a1, 3
+; RV64I-NEXT: add a0, a0, a1
+; RV64I-NEXT: add a0, a0, a2
+; RV64I-NEXT: ret
+;
+; RV64ZBA-LABEL: test_gep_gep_dont_crash:
+; RV64ZBA: # %bb.0:
+; RV64ZBA-NEXT: srliw a2, a2, 6
+; RV64ZBA-NEXT: add a1, a2, a1
+; RV64ZBA-NEXT: sh3add a0, a1, a0
+; RV64ZBA-NEXT: ret
+ %lshr = lshr i64 %a2, 6
+ %and = and i64 %lshr, 67108863
+ %gep1 = getelementptr i64, ptr %p, i64 %and
+ %gep2 = getelementptr i64, ptr %gep1, i64 %a1
+ ret ptr %gep2
+}
More information about the llvm-commits
mailing list