Skip to content

Commit 50561ae

Browse files
committed
[RISCV] Add SRAW to ComputeNumSignBitsForTargetNode.
1 parent 0ad34a6 commit 50561ae

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21451,8 +21451,14 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
2145121451
if (Tmp < 33) return 1;
2145221452
return 33;
2145321453
}
21454+
case RISCVISD::SRAW: {
21455+
unsigned Tmp =
21456+
DAG.ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
21457+
// sraw produces at least 33 sign bits. If the input already has more than
21458+
// 33 sign bits sraw, will preserve them.
21459+
return std::max(Tmp, 33U);
21460+
}
2145421461
case RISCVISD::SLLW:
21455-
case RISCVISD::SRAW:
2145621462
case RISCVISD::SRLW:
2145721463
case RISCVISD::DIVW:
2145821464
case RISCVISD::DIVUW:

llvm/test/CodeGen/RISCV/rv64i-shift-sext.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ define signext i32 @test15(i32 signext %x, i32 signext %y) {
228228
; RV64I: # %bb.0:
229229
; RV64I-NEXT: srli a0, a0, 1
230230
; RV64I-NEXT: sraw a0, a0, a1
231-
; RV64I-NEXT: slliw a0, a0, 1
231+
; RV64I-NEXT: slli a0, a0, 1
232232
; RV64I-NEXT: ret
233233
%a = ashr i32 %x, 1
234234
%b = ashr i32 %a, %y

0 commit comments

Comments
 (0)