<div dir="ltr">I am going to take the approach suggested by Sanjay and expand isFNEG to handle splat of a negated scalar. Then, the current combineFMA should take care of the rest. I got the isFNEG to work with shuffle (and work on the current test case) but haven't yet handled the insertelement case. I am out traveling for the next ten days and will send a revised patch after I am back.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 22, 2018 at 11:45 AM, Simon Pilgrim via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">RKSimon added inline comments.<br>
<br>
<br>
================<br>
</span>Comment at: lib/Target/X86/<wbr>X86ISelLowering.cpp:31185<br>
+    return Negate(Op0, Op1);<br>
+}<br>
+<br>
----------------<br>
Please move the isFNEG as a NFC commit<br>
<br>
<br>
================<br>
Comment at: lib/Target/X86/<wbr>X86ISelLowering.cpp:31210<br>
+      break;<br>
+    }<br>
+  if (!UsedByFMA)<br>
----------------<br>
Can this be written as a llvm::any_of pattern?<br>
<br>
<br>
================<br>
Comment at: lib/Target/X86/<wbr>X86ISelLowering.cpp:31214<br>
+<br>
+  ShuffleVectorSDNode *SVOp = dyn_cast<ShuffleVectorSDNode>(<wbr>N);<br>
+  auto NegOp0 = isFNEG(N->getOperand(0).<wbr>getNode());<br>
----------------<br>
Early out if !SVOp || !SVOp->isSplat()<br>
<br>
<br>
================<br>
Comment at: lib/Target/X86/<wbr>X86ISelLowering.cpp:31215<br>
+  ShuffleVectorSDNode *SVOp = dyn_cast<ShuffleVectorSDNode>(<wbr>N);<br>
+  auto NegOp0 = isFNEG(N->getOperand(0).<wbr>getNode());<br>
+<br>
----------------<br>
Don't use auto for non-obvious (casts etc.) cases.<br>
<br>
<br>
================<br>
Comment at: lib/Target/X86/<wbr>X86ISelLowering.cpp:31218<br>
+  if (SVOp && SVOp->isSplat() && NegOp0.getNode() &&<br>
+      N->getOperand(1).isUndef()) {<br>
+    EVT VT = N->getValueType(0);<br>
----------------<br>
Its unlikely that Op1 isn't undef, but if you have cases of this you could handle both ops but testing SVOp->getSplatIndex()<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D48467" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D48467</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div>