Skip to content

Commit

Permalink
[RISCV] Make shouldConvertConstantLoadToIntImm return true unless ena…
Browse files Browse the repository at this point in the history
…bleUnalignedScalarMem is true.

This restores the old behavior before D129402 when
enableUnalignedScalarMem is false. This fixes a regression spotted
by @asb.

To fix this correctly, we need to consider alignment of the load
we'd be replacing, but that's not possible in the current interface.
  • Loading branch information
topperc committed Jul 11, 2022
1 parent d0eec5f commit 1a2bd44
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Expand Up @@ -1174,6 +1174,13 @@ bool RISCVTargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
if (isInt<32>(Val))
return true;

// A constant pool entry may be more aligned thant he load we're trying to
// replace. If we don't support unaligned scalar mem, prefer the constant
// pool.
// TODO: Can the caller pass down the alignment?
if (!Subtarget.enableUnalignedScalarMem())
return true;

// Prefer to keep the load if it would require many instructions.
// This uses the same threshold we use for constant pools but doesn't
// check useConstantPoolForLargeInts.
Expand Down

0 comments on commit 1a2bd44

Please sign in to comment.