<html><head><base href="x-msg://56/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 27, 2011, at 11:13 PM, Jonas Paulsson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">Hi,<br><br>I would like to transform a LLVM function containing a load and an add of the base address inside a loop to a post-incremented load. In DAGCombiner.cpp::CombineToPostIndexedLoadStore(), it says it cannot fold the add for instance if it is a predecessor/successor of the load. I find this odd, as this<br>is exactly what I would like to handle: a simple loop with an address that is inremented in each iteration.<br><br>I am considering using a target intrinsic for this purpose, as the SCEV interface is available on the LLVM I/R. In this way, I could get a DAG with a post-inc-load node instead of the load and add nodes.<br><br>Is this a work in progress? Please explain why these constraints are put in the above mentioned method as they do not seem to facilitate post-inc instruction combining.</div></span></blockquote><br></div><div>The "predecessor" and "successor" terminology used there refers to the DAG, not to the order of the operations in the llvm IR.  For example, if the result of the ADD is the value being stored to memory, then you couldn't fold that into into a post-inc STORE:</div><div><br></div><div> %x = add i32 %addr, 4;</div><div> store i32 %x, i32* %addr</div><div><br></div><div>In the DAG for that, the ADD is a predecessor of the STORE.  If the result of the add is used for some other memory reference, then it would not be a predecessor and could be folded.</div></body></html>