<div dir="ltr">I'd like to apologize in advance if the question seems dumb, but I've never specified a DAG pattern for an instruction a don't know how it looks in LLVM.<div><br></div><div>My target has an instruction which is similar to X86 horizontal add. The instruction, let's call is sumreduce, sums up all the elements in a vector and stores a result in GPR. What I'm trying to do is to replace a specific DAG pattern (it is given below) with this instruction (DAG node).</div><div><br></div><div>Here is the pattern I need to replace:</div><div><br></div><div><div style="font-size:12.8px"> r0 r1 </div><div style="font-size:12.8px"> \ /</div><div style="font-size:12.8px"> add r2</div><div style="font-size:12.8px"> \ /</div><div style="font-size:12.8px"> add r3</div><div style="font-size:12.8px"> \ /</div><div style="font-size:12.8px"> add</div><div style="font-size:12.8px"> |</div></div><div style="font-size:12.8px"> r4</div><div><div><br></div><div>with</div><div> r4 = sumreduce r0 r1 r2 r3</div><div><br></div><div>For now assume that the vector has 4 elements in it and all of them are i32.</div><div><br></div><div>I would appreciate any pointers on how to do it. If someone could point me to an example code that converts a DAG pattern to a DAG node I would greatly appreciate it.</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</div></div>