Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/ExpandMemCmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,15 @@ Value *MemCmpExpansion::getMemCmpOneBlock() {
if (CI->hasOneUser()) {
auto *UI = cast<Instruction>(*CI->user_begin());
CmpPredicate Pred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
uint64_t Shift;
bool NeedsZExt = false;
// This is a special case because instead of checking if the result is less
// than zero:
// bool result = memcmp(a, b, NBYTES) < 0;
// Compiler is clever enough to generate the following code:
// bool result = memcmp(a, b, NBYTES) >> 31;
if (match(UI, m_LShr(m_Value(), m_ConstantInt(Shift))) &&
Shift == (CI->getType()->getIntegerBitWidth() - 1)) {
if (match(UI,
m_LShr(m_Value(),
m_SpecificInt(CI->getType()->getIntegerBitWidth() - 1)))) {
Pred = ICmpInst::ICMP_SLT;
NeedsZExt = true;
} else {
Expand Down
Loading