Skip to content

Commit 1ecdbf2

Browse files
authored
[RISCV] Add SRAI to recursive part of isSignExtendedW. (#157164)
SRAI can only increase the number of sign bits. If the input has at least 33 sign bits, the result will to. I don't have a test case for this currently. It was just an observation I made while thinking about the shifts and extracts.
1 parent b9b0ea5 commit 1ecdbf2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,11 @@ static bool isSignExtendedW(Register SrcReg, const RISCVSubtarget &ST,
529529
case RISCV::ANDI:
530530
case RISCV::ORI:
531531
case RISCV::XORI:
532+
case RISCV::SRAI:
532533
// |Remainder| is always <= |Dividend|. If D is 32-bit, then so is R.
533534
// DIV doesn't work because of the edge case 0xf..f 8000 0000 / (long)-1
534535
// Logical operations use a sign extended 12-bit immediate.
536+
// Arithmetic shift right can only increase the number of sign bits.
535537
if (!AddRegToWorkList(MI->getOperand(1).getReg()))
536538
return false;
537539

0 commit comments

Comments
 (0)