Skip to content

Commit f276729

Browse files
committed
[RISCV] Replace an explicit check with an assert.
Shift amounts should never be 0 or more than bitwidth - 1.
1 parent 66790b7 commit f276729

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,9 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
854854
auto *C = dyn_cast<ConstantSDNode>(N0.getOperand(1));
855855
if (!C)
856856
break;
857-
uint64_t C2 = C->getZExtValue();
857+
unsigned C2 = C->getZExtValue();
858858
unsigned XLen = Subtarget->getXLen();
859-
if (!C2 || C2 >= XLen)
860-
break;
859+
assert((C2 > 0 && C2 < XLen) && "Unexpected shift amount!");
861860

862861
uint64_t C1 = N1C->getZExtValue();
863862

0 commit comments

Comments
 (0)