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 | b42aef4925b7679268f222b3ba55b08b66bdcb37 (patch) | |
tree | 3fb227b1553d8df09802c6cd5b5b75688ae9d9d0 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 336d62e99a080863ed1f41ac5d6c1c7d49502b22 (diff) | |
download | bcm5719-llvm-b42aef4925b7679268f222b3ba55b08b66bdcb37.tar.gz bcm5719-llvm-b42aef4925b7679268f222b3ba55b08b66bdcb37.zip |
Fix bug in PR454 resolution. Added new test case.
This fixes llvmAsmParser.cpp miscompile by llvm on PowerPC Darwin.
llvm-svn: 31053
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index f0961de5274..9ebb5305b6f 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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. |