<div dir="ltr">Ah, I didn't think of the swapOperands() as a mutation, but of course you're right. I don't see any precedent for that, so I suppose it's safer to just create some temps with the swapped values.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 6, 2016 at 2:18 PM, Friedman, Eli <span dir="ltr"><<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 12/6/2016 10:09 AM, Sanjay Patel via llvm-commits wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: spatel<br>
Date: Tue Dec  6 12:09:37 2016<br>
New Revision: 288833<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=288833&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=288833&view=rev</a><br>
Log:<br>
[InstSimplify] add folds for or-of-icmps with same operands<br>
<br>
All of these (and a few more) are already handled by InstCombine,<br>
but we shouldn't have to wait until then to simplify these because<br>
they're cheap to deal with here in InstSimplify.<br>
<br>
Modified:<br>
     llvm/trunk/lib/Analysis/Instr<wbr>uctionSimplify.cpp<br>
     llvm/trunk/test/Transforms/In<wbr>stSimplify/or-icmps-same-ops.<wbr>ll<br>
<br>
Modified: llvm/trunk/lib/Analysis/Instru<wbr>ctionSimplify.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=288833&r1=288832&r2=288833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Analysis/<wbr>InstructionSimplify.cpp?rev=<wbr>288833&r1=288832&r2=288833&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Analysis/Instru<wbr>ctionSimplify.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/Instru<wbr>ctionSimplify.cpp Tue Dec  6 12:09:37 2016<br>
@@ -1700,12 +1700,44 @@ Value *llvm::SimplifyAndInst(Value *Op0,<br>
                             RecursionLimit);<br>
  }<br>
  -/// Simplify (or (icmp ...) (icmp ...)) to true when we can tell that the union<br>
-/// contains all possible values.<br>
+/// Commuted variants are assumed to be handled by calling this function again<br>
+/// with the parameters swapped.<br>
+static Value *simplifyOrOfICmpsWithSameOper<wbr>ands(ICmpInst *Op0, ICmpInst *Op1) {<br>
+  ICmpInst::Predicate Pred0, Pred1;<br>
+  Value *A ,*B;<br>
+  match(Op0, m_ICmp(Pred0, m_Value(A), m_Value(B)));<br>
+  if (match(Op1, m_ICmp(Pred1, m_Specific(B), m_Specific(A))))<br>
+    Op1->swapOperands();<br>
</blockquote>
<br></div></div>
Is InstSimplify allowed to mutate instructions?<span class="HOEnZb"><font color="#888888"><br>
<br>
-Eli<br>
<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</font></span></blockquote></div><br></div>