summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-02-25 01:02:18 +0000
committerJustin Bogner <mail@justinbogner.com>2016-02-25 01:02:18 +0000
commit08154bf3d2539a3a74af6a4a3822c566ab329b14 (patch)
treed48d7d9d31b31ed35bd34cd4fe993d6ebb52f668 /llvm/lib/IR/ConstantFold.cpp
parent479d545ca2d499f791a84722e0c84f1aa55428b8 (diff)
downloadbcm5719-llvm-08154bf3d2539a3a74af6a4a3822c566ab329b14.tar.gz
bcm5719-llvm-08154bf3d2539a3a74af6a4a3822c566ab329b14.zip
IR: Make the X / undef -> undef fold match the comment
The constant folding for sdiv and udiv has a big discrepancy between the comments and the code, which looks like a typo. Currently, we're folding X / undef pretty inconsistently: 0 / undef -> undef C / undef -> 0 undef / undef -> 0 Whereas the comments state we do X / undef -> undef. The logic that returns zero is actually commented as doing undef / X -> 0, despite that the LHS isn't undef in many of the cases that hit it. llvm-svn: 261813
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 00ff9788a9c..aea8308e9c6 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -948,7 +948,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
case Instruction::SDiv:
case Instruction::UDiv:
// X / undef -> undef
- if (match(C1, m_Zero()))
+ if (isa<UndefValue>(C2))
return C2;
// undef / 0 -> undef
// undef / 1 -> undef
OpenPOWER on IntegriCloud