Constant exprs are not efficiently negatable in practice. This disables
authorChris Lattner <sabre@nondot.org>
Tue, 14 Dec 2004 20:08:06 +0000 (20:08 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Dec 2004 20:08:06 +0000 (20:08 +0000)
turning X - (constantexpr) into X + (-constantexpr) among other things.

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

lib/Transforms/Scalar/InstructionCombining.cpp

index 807653b56d12637609b715273773e846fe9e42f3..f78a14d4273965af80882fa92500006425a88f85 100644 (file)
@@ -309,10 +309,9 @@ static inline Value *dyn_castNegVal(Value *V) {
   if (BinaryOperator::isNeg(V))
     return BinaryOperator::getNegArgument(cast<BinaryOperator>(V));
 
-  // Constants can be considered to be negated values if they can be folded...
-  if (Constant *C = dyn_cast<Constant>(V))
-    if (!isa<UndefValue>(C))
-      return ConstantExpr::getNeg(C);
+  // Constants can be considered to be negated values if they can be folded.
+  if (ConstantInt *C = dyn_cast<ConstantInt>(V))
+    return ConstantExpr::getNeg(C);
   return 0;
 }