diff options
author | Devang Patel <dpatel@apple.com> | 2006-10-19 18:54:08 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-10-19 18:54:08 +0000 |
commit | 6ce890b6ec6ee7823a225608967a94cc6bdbd06e (patch) | |
tree | 4a63d4bb778f6df42e08501d30f878af5035250b /lib/Transforms | |
parent | 2435786414ac5e3eccddc6dc8252421f627aee6a (diff) |
Fix bug in PR454 resolution. Added new test case.
This fixes llvmAsmParser.cpp miscompile by llvm on PowerPC Darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31053 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f0961de527..9ebb5305b6 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4785,7 +4785,21 @@ Instruction *InstCombiner::visitSetCondInstWithCastAndCast(SetCondInst &SCI) { 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. |