[llvm] 1a2bd44 - [RISCV] Make shouldConvertConstantLoadToIntImm return true unless enableUnalignedScalarMem is true.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 11 09:40:24 PDT 2022
Author: Craig Topper
Date: 2022-07-11T09:40:08-07:00
New Revision: 1a2bd44b77c2dd0c2aabf5e27e30eb17c4715832
URL: https://github.com/llvm/llvm-project/commit/1a2bd44b77c2dd0c2aabf5e27e30eb17c4715832
DIFF: https://github.com/llvm/llvm-project/commit/1a2bd44b77c2dd0c2aabf5e27e30eb17c4715832.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 9c16da946e84..066c57614e34 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -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.
More information about the llvm-commits
mailing list