Skip to content

Commit 1c38d74

Browse files
committed
Move the selection of 0 into tryUnsignedBitfieldInsertInZero
1 parent de9c8ce commit 1c38d74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ bool RISCVDAGToDAGISel::tryUnsignedBitfieldInsertInZero(SDNode *Node, SDLoc DL,
698698

699699
unsigned Opc = RISCV::NDS_BFOZ;
700700

701+
// If the Lsb is equal to the Msb, then the Lsb should be 0.
702+
if (Lsb == Msb)
703+
Lsb = 0;
701704
SDNode *Ubi = CurDAG->getMachineNode(Opc, DL, VT, X,
702705
CurDAG->getTargetConstant(Lsb, DL, VT),
703706
CurDAG->getTargetConstant(Msb, DL, VT));
@@ -1350,8 +1353,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
13501353
// If XLen = 32 and C2 = 12, then
13511354
// Msb = 32 - 8 - 1 = 23 and Lsb = 12
13521355
const unsigned Msb = XLen - Leading - 1;
1353-
// If Msb is equal to C2, the Lsb will be 0 instead of C2.
1354-
unsigned Lsb = Msb == C2 ? 0 : C2;
1356+
const unsigned Lsb = C2;
13551357
if (tryUnsignedBitfieldInsertInZero(Node, DL, VT, X, Msb, Lsb))
13561358
return;
13571359

0 commit comments

Comments
 (0)