[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jul 18 16:07:44 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.357 -> 1.358
---
Log message:
When transforming &A[i] < &A[j] -> i < j, make sure to perform the comparison
as a signed compare. This patch may fix PR597: http://llvm.cs.uiuc.edu/PR597 , but is correct in any case.
---
Diffs of the changes: (+11 -4)
InstructionCombining.cpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.357 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.358
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.357 Thu Jul 7 15:40:38 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 18 18:07:33 2005
@@ -2367,10 +2367,17 @@
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);
- return new SetCondInst(Cond, LHSV, RHSV);
+
+ // 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);
}
}
More information about the llvm-commits
mailing list