[RISCV] Replace an explicit check with an assert.
authorCraig Topper <craig.topper@sifive.com>
Tue, 5 Jul 2022 05:33:15 +0000 (22:33 -0700)
committerCraig Topper <craig.topper@sifive.com>
Tue, 5 Jul 2022 06:21:54 +0000 (23:21 -0700)
Shift amounts should never be 0 or more than bitwidth - 1.

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

index c4043b6..334ee49 100644 (file)
@@ -854,10 +854,9 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
     auto *C = dyn_cast<ConstantSDNode>(N0.getOperand(1));
     if (!C)
       break;
-    uint64_t C2 = C->getZExtValue();
+    unsigned C2 = C->getZExtValue();
     unsigned XLen = Subtarget->getXLen();
-    if (!C2 || C2 >= XLen)
-      break;
+    assert((C2 > 0 && C2 < XLen) && "Unexpected shift amount!");
 
     uint64_t C1 = N1C->getZExtValue();