mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 18:29:45 +00:00
Avoid undefined behavior in negation in LSR. Patch by Ahmed Charles.
Someone more familiar with LSR should double-check that the extra cast is actually doing the right thing in the overflow cases; I'm not completely confident that's that case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141916 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ecb830e45c
commit
dae36ba802
@ -1205,7 +1205,7 @@ static bool isLegalUse(const TargetLowering::AddrMode &AM,
|
|||||||
// If we have low-level target information, ask the target if it can fold an
|
// If we have low-level target information, ask the target if it can fold an
|
||||||
// integer immediate on an icmp.
|
// integer immediate on an icmp.
|
||||||
if (AM.BaseOffs != 0) {
|
if (AM.BaseOffs != 0) {
|
||||||
if (TLI) return TLI->isLegalICmpImmediate(-AM.BaseOffs);
|
if (TLI) return TLI->isLegalICmpImmediate(-(uint64_t)AM.BaseOffs);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3593,7 +3593,7 @@ Value *LSRInstance::Expand(const LSRFixup &LF,
|
|||||||
// The other interesting way of "folding" with an ICmpZero is to use a
|
// The other interesting way of "folding" with an ICmpZero is to use a
|
||||||
// negated immediate.
|
// negated immediate.
|
||||||
if (!ICmpScaledV)
|
if (!ICmpScaledV)
|
||||||
ICmpScaledV = ConstantInt::get(IntTy, -Offset);
|
ICmpScaledV = ConstantInt::get(IntTy, -(uint64_t)Offset);
|
||||||
else {
|
else {
|
||||||
Ops.push_back(SE.getUnknown(ICmpScaledV));
|
Ops.push_back(SE.getUnknown(ICmpScaledV));
|
||||||
ICmpScaledV = ConstantInt::get(IntTy, Offset);
|
ICmpScaledV = ConstantInt::get(IntTy, Offset);
|
||||||
|
Loading…
Reference in New Issue
Block a user