aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-21 01:15:55 +0000
committerChris Lattner <sabre@nondot.org>2009-06-21 01:15:55 +0000
commit1db6866147b6b3028fdc77bc242de8f44edd71d9 (patch)
tree5571ed155bd82f9ffc8b4d968e6ba4b0e1145ece /lib/VMCore
parent5c0b16d0c40bb95e572e5d24db587ed8ca4bde71 (diff)
downloadexternal_llvm-1db6866147b6b3028fdc77bc242de8f44edd71d9.zip
external_llvm-1db6866147b6b3028fdc77bc242de8f44edd71d9.tar.gz
external_llvm-1db6866147b6b3028fdc77bc242de8f44edd71d9.tar.bz2
implement PR4424: 0/x is always 0 for integer division.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73835 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 6c39214..dc8fb39 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -773,6 +773,13 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
}
}
}
+
+ // 0 / x -> 0.
+ if ((Opcode == Instruction::UDiv ||
+ Opcode == Instruction::SDiv) &&
+ CI1->isZero())
+ return const_cast<Constant*>(C1);
+
} else if (const ConstantFP *CFP1 = dyn_cast<ConstantFP>(C1)) {
if (const ConstantFP *CFP2 = dyn_cast<ConstantFP>(C2)) {
APFloat C1V = CFP1->getValueAPF();