<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 12, 2010, at 8:15 PM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: lattner<br>Date: Sun Dec 12 22:15:19 2010<br>New Revision: 121675<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=121675&view=rev">http://llvm.org/viewvc/llvm-project?rev=121675&view=rev</a><br>Log:<br>inline a function, making the result much simpler.<br><br></div></blockquote><div>Chris,</div><div><br></div><div>This doesn't have the same semantics as the original non-inlined version. TrueWhenEqual should be "false" if the dyn_cast fails.</div><div><br></div><div>-bw</div><br><blockquote type="cite"><div>Modified:<br> llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp<br><br>Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=121675&r1=121674&r2=121675&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=121675&r1=121674&r2=121675&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Dec 12 22:15:19 2010<br>@@ -347,31 +347,6 @@<br> return 0;<br> }<br><br>-/// GatherValueComparisons - If the specified Cond is an 'and' or 'or' of a<br>-/// bunch of comparisons of one value against constants, return the value and<br>-/// the constants being compared.<br>-static bool GatherValueComparisons(Value *CondV, Value *&CompVal,<br>- std::vector<ConstantInt*> &Values,<br>- const TargetData *TD) {<br>- Instruction *Cond = dyn_cast<Instruction>(CondV);<br>- if (Cond == 0) return false;<br>- <br>- if (Cond->getOpcode() == Instruction::Or) {<br>- CompVal = GatherConstantSetEQs(Cond, Values, TD);<br>-<br>- // Return true to indicate that the condition is true if the CompVal is<br>- // equal to one of the constants.<br>- return true;<br>- }<br>- if (Cond->getOpcode() == Instruction::And) {<br>- CompVal = GatherConstantSetNEs(Cond, Values, TD);<br>-<br>- // Return false to indicate that the condition is false if the CompVal is<br>- // equal to one of the constants.<br>- return false;<br>- }<br>- return false;<br>-}<br><br> static void EraseTerminatorInstAndDCECond(TerminatorInst *TI) {<br> Instruction* Cond = 0;<br>@@ -2096,8 +2071,17 @@<br> // 'setne's and'ed together, collect them.<br> Value *CompVal = 0;<br> std::vector<ConstantInt*> Values;<br>- bool TrueWhenEqual = GatherValueComparisons(BI->getCondition(), CompVal,<br>- Values, TD);<br>+ bool TrueWhenEqual = true;<br>+ <br>+ if (Instruction *Cond = dyn_cast<Instruction>(BI->getCondition())) {<br>+ if (Cond->getOpcode() == Instruction::Or) {<br>+ CompVal = GatherConstantSetEQs(Cond, Values, TD);<br>+ } else if (Cond->getOpcode() == Instruction::And) {<br>+ CompVal = GatherConstantSetNEs(Cond, Values, TD);<br>+ TrueWhenEqual = false;<br>+ }<br>+ }<br>+<br> if (CompVal) {<br> // There might be duplicate constants in the list, which the switch<br> // instruction can't handle, remove them now.<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></div></blockquote></div><br></body></html>