Fix InstCombine/2006-11-10-ashr-miscompile.ll a miscompilation introduced
authorChris Lattner <sabre@nondot.org>
Fri, 10 Nov 2006 23:38:52 +0000 (23:38 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 10 Nov 2006 23:38:52 +0000 (23:38 +0000)
by the shr -> [al]shr patch.  This was reduced from 176.gcc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31653 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 65ebf641d6fa026af134562af5c506408f266e80..f636442bb7fecee68419ee740c617c046f29236d 100644 (file)
@@ -5082,10 +5082,10 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
       return ReplaceInstUsesWith(I, Op0);          // X >>s undef -> X
   }
 
-  // shr int -1, X = -1   (for any arithmetic shift rights of ~0)
-  if (!isLeftShift)
+  // ashr int -1, X = -1   (for any arithmetic shift rights of ~0)
+  if (I.getOpcode() == Instruction::AShr)
     if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0))
-      if (CSI->isAllOnesValue() && Op0->getType()->isSigned())
+      if (CSI->isAllOnesValue())
         return ReplaceInstUsesWith(I, CSI);
 
   // Try to fold constant and into select arguments.