Skip to content

Commit 1a2bd44

Browse files
committed
[RISCV] Make shouldConvertConstantLoadToIntImm return true unless enableUnalignedScalarMem 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.
1 parent d0eec5f commit 1a2bd44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,13 @@ bool RISCVTargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
11741174
if (isInt<32>(Val))
11751175
return true;
11761176

1177+
// A constant pool entry may be more aligned thant he load we're trying to
1178+
// replace. If we don't support unaligned scalar mem, prefer the constant
1179+
// pool.
1180+
// TODO: Can the caller pass down the alignment?
1181+
if (!Subtarget.enableUnalignedScalarMem())
1182+
return true;
1183+
11771184
// Prefer to keep the load if it would require many instructions.
11781185
// This uses the same threshold we use for constant pools but doesn't
11791186
// check useConstantPoolForLargeInts.

0 commit comments

Comments
 (0)