Hello LLVMdev,<div><br></div><div>Our processor has mac (multiply and accumulate) instructions which takes the accumulator register (acc) as an implicit operand. This is different from typical three or four operands mac instructions. As an illustration, the following instructions compute a + b x c + e x f + g *h.</div>

<div><br></div><div><br></div><div>initacc  a                         //initialize the accumulator register</div><div>fmac b c</div><div>fmac e f</div><div>fmac g h</div><div>mfacc i                             //move result from the accumulator register to register i</div>

<div><br></div><div>A straightforward implementation is to find the patterns in selectionDAG and turn them into mac instructions chains like above. One chain of mac instructions (with initacc at the beginning and mfacc at the end) may be glued together to be one unit, so that the scheduler would not interleave instructions from different chains.</div>

<div><br></div><div>However this implementation is not efficient.</div><div><ol><li>The scheduler cannot insert instructions between mac instructions to fill pipeline bubble, since one chain is one schedule unit.</li><li>

Register pressure will be high if the mac chains are long, since all the input registers of one chain are alive at the same time.</li></ol>I try to solve the problem by not just glue one chain of mac instructions together,  instead by using virtual data dependency and implicit physical register dependency. I do get good results. However my implementation needs to modify target-independent llvm scheduler code, so it is not flexible and error-prone. </div>
<div><br></div><div>I would much appreciate if you could give some suggestions or bring some ideas. Thanks!</div><div><br></div><div>Best regards,</div><div>David</div><div><br></div><div><br></div><div><br></div>