Skip to content
Merged
5 changes: 3 additions & 2 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14325,10 +14325,11 @@ static bool checkAddiForShift(SDValue AddI, int64_t &AddConst,

APInt AddVal;
SDValue SHLVal;
sd_match(AddI, m_Add(m_Value(SHLVal), m_ConstInt(AddVal)));
assert(sd_match(AddI, m_Add(m_Value(SHLVal), m_ConstInt(AddVal))) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire sd_match statement will not be executed if LLVM is not built with assertion enabled (e.g. normal Release build). I would recommend something like this:

bool IsAddI = sd_match(AddI, ...);
assert(IsAddI && "...");
(void)IsAddI;

"Expected an addi with a constant addition.");

APInt VShift;
if (!sd_match(SHLVal, m_c_BinOp(ISD::SHL, m_Value(), m_ConstInt(VShift))))
if (!sd_match(SHLVal, m_BinOp(ISD::SHL, m_Value(), m_ConstInt(VShift))))
return false;

if (VShift.slt(1) || VShift.sgt(3))
Expand Down