[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Devang Patel
dpatel at apple.com
Thu Oct 19 11:54:23 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.520 -> 1.521
---
Log message:
Fix bug in PR454: http://llvm.org/PR454 resolution. Added new test case.
This fixes llvmAsmParser.cpp miscompile by llvm on PowerPC Darwin.
---
Diffs of the changes: (+15 -1)
InstructionCombining.cpp | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletion(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.521
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520 Mon Oct 16 18:08:08 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Oct 19 13:54:08 2006
@@ -4785,7 +4785,21 @@
Constant *Res = ConstantExpr::getCast(CI, SrcTy);
if (ConstantExpr::getCast(Res, DestTy) == CI) {
- RHSCIOp = Res;
+ // Make sure that src sign and dest sign match. For example,
+ //
+ // %A = cast short %X to uint
+ // %B = setgt uint %A, 1330
+ //
+ // It is incorrect to transformt this into
+ //
+ // %B = setgt short %X, 1330
+ //
+ // because %A may have negative value.
+ // However, it is OK if SrcTy is bool. See cast-set.ll testcase.
+ if (isSignSrc == isSignDest || SrcTy == Type::BoolTy)
+ RHSCIOp = Res;
+ else
+ return 0;
} else {
// If the value cannot be represented in the shorter type, we cannot emit
// a simple comparison.
More information about the llvm-commits
mailing list