Author: hans Date: Wed Aug 12 11:51:20 2015 New Revision: 244764 URL: http://llvm.org/viewvc/llvm-project?rev=244764&view=rev Log: Merging r244676: ------------------------------------------------------------------------ r244676 | sanjoy | 2015-08-11 14:33:55 -0700 (Tue, 11 Aug 2015) | 7 lines
Fix PR24354. `InstCombiner::OptimizeOverflowCheck` was asserting an invariant (operands to binary operations are ordered by decreasing complexity) that wasn't really an invariant. Fix this by instead having `InstCombiner::OptimizeOverflowCheck` establish the invariant if it does not hold. ------------------------------------------------------------------------ Added: llvm/branches/release_37/test/Transforms/InstCombine/pr24354.ll - copied unchanged from r244676, llvm/trunk/test/Transforms/InstCombine/pr24354.ll Modified: llvm/branches/release_37/ (props changed) llvm/branches/release_37/lib/Transforms/InstCombine/InstCombineCompares.cpp Propchange: llvm/branches/release_37/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Aug 12 11:51:20 2015 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,242236,242239,242281,242288,242296,242331,242341,242410,242412,242433-242434,242442,242543,242673,242680,242706,242721-242722,242733-242735,242742,242869,242919,242993,243001,243057,243116,243263,243294,243361,243469,243485,243500,243519,243531,243589,243609,243636,243638-243640,243745,243891,243898,243927,243932,243934,243984,243986,244058,244123,244418,244554,244644 +/llvm/trunk:155241,242236,242239,242281,242288,242296,242331,242341,242410,242412,242433-242434,242442,242543,242673,242680,242706,242721-242722,242733-242735,242742,242869,242919,242993,243001,243057,243116,243263,243294,243361,243469,243485,243500,243519,243531,243589,243609,243636,243638-243640,243745,243891,243898,243927,243932,243934,243984,243986,244058,244123,244418,244554,244644,244676 Modified: llvm/branches/release_37/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=244764&r1=244763&r2=244764&view=diff ============================================================================== --- llvm/branches/release_37/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/branches/release_37/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Aug 12 11:51:20 2015 @@ -2112,9 +2112,8 @@ static Instruction *ProcessUGT_ADDCST_AD bool InstCombiner::OptimizeOverflowCheck(OverflowCheckFlavor OCF, Value *LHS, Value *RHS, Instruction &OrigI, Value *&Result, Constant *&Overflow) { - assert((!OrigI.isCommutative() || - !(isa<Constant>(LHS) && !isa<Constant>(RHS))) && - "call with a constant RHS if possible!"); + if (OrigI.isCommutative() && isa<Constant>(LHS) && !isa<Constant>(RHS)) + std::swap(LHS, RHS); auto SetResult = [&](Value *OpResult, Constant *OverflowVal, bool ReuseName) { Result = OpResult; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits