Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Issue 183273009: Prep for merging 3.4: Undo changes from 3.3 branch (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Transforms/IPO/GlobalOpt.cpp ('k') | lib/Transforms/Scalar/CodeGenPrepare.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- InstCombineMulDivRem.cpp -------------------------------------------===// 1 //===- InstCombineMulDivRem.cpp -------------------------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the visit functions for mul, fmul, sdiv, udiv, fdiv, 10 // This file implements the visit functions for mul, fmul, sdiv, udiv, fdiv,
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 T->setDebugLoc(I.getDebugLoc()); 518 T->setDebugLoc(I.getDebugLoc());
519 519
520 Instruction *R = BinaryOperator::CreateFMul(T, Y); 520 Instruction *R = BinaryOperator::CreateFMul(T, Y);
521 R->copyFastMathFlags(&I); 521 R->copyFastMathFlags(&I);
522 return R; 522 return R;
523 } 523 }
524 } 524 }
525 } 525 }
526 526
527 // B * (uitofp i1 C) -> select C, B, 0 527 // B * (uitofp i1 C) -> select C, B, 0
528 if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { 528 if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
529 Value *LHS = Op0, *RHS = Op1; 529 Value *LHS=Op0, *RHS=Op1;
530 Value *B, *C; 530 Value *B, *C;
531 if (!match(RHS, m_UIToFp(m_Value(C)))) 531 if (!match(RHS, m_UIToFp(m_Value(C))))
532 std::swap(LHS, RHS); 532 std::swap(LHS, RHS);
533 533
534 if (match(RHS, m_UIToFp(m_Value(C))) && C->getType()->isIntegerTy(1)) { 534 if (match(RHS, m_UIToFp(m_Value(C)))) {
535 B = LHS; 535 B=LHS;
536 Value *Zero = ConstantFP::getNegativeZero(B->getType()); 536 Value *Zero = ConstantFP::getNegativeZero(B->getType());
537 return SelectInst::Create(C, B, Zero); 537 return SelectInst::Create(C, B, Zero);
538 } 538 }
539 } 539 }
540 540
541 // A * (1 - uitofp i1 C) -> select C, 0, A 541 // A * (1 - uitofp i1 C) -> select C, 0, A
542 if (I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) { 542 if(I.hasNoNaNs() && I.hasNoInfs() && I.hasNoSignedZeros()) {
543 Value *LHS = Op0, *RHS = Op1; 543 Value *LHS=Op0, *RHS=Op1;
544 Value *A, *C; 544 Value *A, *C;
545 if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) 545 if (!match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))))
546 std::swap(LHS, RHS); 546 std::swap(LHS, RHS);
547 547
548 if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C)))) && 548 if (match(RHS, m_FSub(m_FPOne(), m_UIToFp(m_Value(C))))) {
549 C->getType()->isIntegerTy(1)) { 549 A=LHS;
550 A = LHS; 550 Value *Zero = ConstantFP::getNegativeZero(A->getType());
551 Value *Zero = ConstantFP::getNegativeZero(A->getType()); 551 return SelectInst::Create(C, Zero, A);
552 return SelectInst::Create(C, Zero, A); 552 }
553 }
554 } 553 }
555 554
556 if (!isa<Constant>(Op1)) 555 if (!isa<Constant>(Op1))
557 std::swap(Opnd0, Opnd1); 556 std::swap(Opnd0, Opnd1);
558 else 557 else
559 break; 558 break;
560 } 559 }
561 560
562 return Changed ? &I : 0; 561 return Changed ? &I : 0;
563 } 562 }
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1136
1138 if (Value *V = SimplifyFRemInst(Op0, Op1, TD)) 1137 if (Value *V = SimplifyFRemInst(Op0, Op1, TD))
1139 return ReplaceInstUsesWith(I, V); 1138 return ReplaceInstUsesWith(I, V);
1140 1139
1141 // Handle cases involving: rem X, (select Cond, Y, Z) 1140 // Handle cases involving: rem X, (select Cond, Y, Z)
1142 if (isa<SelectInst>(Op1) && SimplifyDivRemOfSelect(I)) 1141 if (isa<SelectInst>(Op1) && SimplifyDivRemOfSelect(I))
1143 return &I; 1142 return &I;
1144 1143
1145 return 0; 1144 return 0;
1146 } 1145 }
OLDNEW
« no previous file with comments | « lib/Transforms/IPO/GlobalOpt.cpp ('k') | lib/Transforms/Scalar/CodeGenPrepare.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698