diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-04-29 19:23:44 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-04-29 19:23:44 +0000 |
commit | a706b9a90eb99f764c23a913565d06656f8780a4 (patch) | |
tree | b9a6edf3aeee54a9199fdf91bfa095b659e465f5 /llvm/lib | |
parent | 54dbcfe5f017265ae829f054f28745b2680a0fa2 (diff) | |
download | bcm5719-llvm-a706b9a90eb99f764c23a913565d06656f8780a4.tar.gz bcm5719-llvm-a706b9a90eb99f764c23a913565d06656f8780a4.zip |
[InstCombine] reduce code duplication; NFC
Follow-up to:
rL359482
Avoid this potential problem throughout by giving the type a name
and verifying the assumption that both operands are the same type.
llvm-svn: 359485
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index b27ddb779d7..7880067401f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -5481,6 +5481,8 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { return replaceInstUsesWith(I, V); // Simplify 'fcmp pred X, X' + Type *OpType = Op0->getType(); + assert(OpType == Op1->getType() && "fcmp with different-typed operands?"); if (Op0 == Op1) { switch (Pred) { default: break; @@ -5490,7 +5492,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { case FCmpInst::FCMP_UNE: // True if unordered or not equal // Canonicalize these to be 'fcmp uno %X, 0.0'. I.setPredicate(FCmpInst::FCMP_UNO); - I.setOperand(1, Constant::getNullValue(Op0->getType())); + I.setOperand(1, Constant::getNullValue(OpType)); return &I; case FCmpInst::FCMP_ORD: // True if ordered (no nans) @@ -5499,7 +5501,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { case FCmpInst::FCMP_OLE: // True if ordered and less than or equal // Canonicalize these to be 'fcmp ord %X, 0.0'. I.setPredicate(FCmpInst::FCMP_ORD); - I.setOperand(1, Constant::getNullValue(Op0->getType())); + I.setOperand(1, Constant::getNullValue(OpType)); return &I; } } @@ -5508,11 +5510,11 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { // then canonicalize the operand to 0.0. if (Pred == CmpInst::FCMP_ORD || Pred == CmpInst::FCMP_UNO) { if (!match(Op0, m_PosZeroFP()) && isKnownNeverNaN(Op0, &TLI)) { - I.setOperand(0, ConstantFP::getNullValue(Op0->getType())); + I.setOperand(0, ConstantFP::getNullValue(OpType)); return &I; } if (!match(Op1, m_PosZeroFP()) && isKnownNeverNaN(Op1, &TLI)) { - I.setOperand(1, ConstantFP::getNullValue(Op1->getType())); + I.setOperand(1, ConstantFP::getNullValue(OpType)); return &I; } } @@ -5535,7 +5537,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { // The sign of 0.0 is ignored by fcmp, so canonicalize to +0.0: // fcmp Pred X, -0.0 --> fcmp Pred X, 0.0 if (match(Op1, m_AnyZeroFP()) && !match(Op1, m_PosZeroFP())) { - I.setOperand(1, ConstantFP::getNullValue(Op1->getType())); + I.setOperand(1, ConstantFP::getNullValue(OpType)); return &I; } |