Skip to content

Commit 7c66ada

Browse files
committed
fixup! Round to nearest byte
1 parent 297670e commit 7c66ada

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ static bool hasAllNBitUsers(const MachineInstr &OrigMI,
325325

326326
case RISCV::BREV8:
327327
case RISCV::ORC_B:
328-
Worklist.push_back(std::make_pair(UserMI, Bits));
328+
// BREV8 and ORC_B work on bytes. Round Bits down to the nearest byte.
329+
Worklist.push_back(std::make_pair(UserMI, alignDown(Bits, 8)));
329330
break;
330331

331332
case RISCV::PseudoCCMOVGPR:

llvm/test/CodeGen/RISCV/sextw-removal.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,10 @@ define signext i32 @test22(i64 %arg1, i64 %arg2, i64 %arg3) {
16401640
; RV64ZBB-NEXT: srli a0, a0, 28
16411641
; RV64ZBB-NEXT: andi a0, a0, 1234
16421642
; RV64ZBB-NEXT: addi a2, a2, 1
1643-
; RV64ZBB-NEXT: addw a0, a0, a1
1643+
; RV64ZBB-NEXT: add a0, a0, a1
16441644
; RV64ZBB-NEXT: bltu a2, a3, .LBB26_1
16451645
; RV64ZBB-NEXT: # %bb.2: # %bb7
1646+
; RV64ZBB-NEXT: sext.w a0, a0
16461647
; RV64ZBB-NEXT: ret
16471648
;
16481649
; NOREMOVAL-LABEL: test22:

0 commit comments

Comments
 (0)