mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
When transforming &A[i] < &A[j] -> i < j, make sure to perform the comparison
as a signed compare. This patch may fix PR597, but is correct in any case. llvm-svn: 22465
This commit is contained in:
parent
d4f9ab3809
commit
4c9139447d
@ -2367,9 +2367,16 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
|
||||
else if (NumDifferences == 1) {
|
||||
Value *LHSV = GEPLHS->getOperand(DiffOperand);
|
||||
Value *RHSV = GEPRHS->getOperand(DiffOperand);
|
||||
if (LHSV->getType() != RHSV->getType())
|
||||
LHSV = InsertNewInstBefore(new CastInst(LHSV, RHSV->getType(),
|
||||
LHSV->getName()+".c"), I);
|
||||
|
||||
// Convert the operands to signed values to make sure to perform a
|
||||
// signed comparison.
|
||||
const Type *NewTy = LHSV->getType()->getSignedVersion();
|
||||
if (LHSV->getType() != NewTy)
|
||||
LHSV = InsertNewInstBefore(new CastInst(LHSV, NewTy,
|
||||
LHSV->getName()), I);
|
||||
if (RHSV->getType() != NewTy)
|
||||
RHSV = InsertNewInstBefore(new CastInst(RHSV, NewTy,
|
||||
RHSV->getName()), I);
|
||||
return new SetCondInst(Cond, LHSV, RHSV);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user