<div dir="ltr">Apologize, I pressed the wrong key and the message was sent before I completed it.  Bellow is the complete implementation of the custom lowering function:<br><div style><br></div><div style><div>static SDValue LowerExtLoad(SDValue Op, SelectionDAG &DAG) {</div>
<div>  LoadSDNode *LD = dyn_cast<LoadSDNode>(Op.getNode());</div><div>  ISD::LoadExtType ExtType = LD->getExtensionType();</div><div>  </div><div>  if (LD->getExtensionType() == ISD::ZEXTLOAD) {</div><div>    DEBUG(errs() << "ZEXTLOAD\n");</div>
<div>    SDValue Chain = LD->getChain();</div><div>    SDValue Ptr = LD->getBasePtr();</div><div>    DebugLoc dl = Op.getNode()->getDebugLoc();</div><div>    SDValue LdResult = DAG.getExtLoad(ISD::EXTLOAD, dl, MVT::i32,</div>
<div>                                      Chain, Ptr, LD->getPointerInfo(), MVT::i32,</div><div>                                      LD->isVolatile(), LD->isNonTemporal(),</div><div>                                      LD->getAlignment());</div>
<div>    Chain = LdResult.getValue(1);</div><div>    SDValue Mask = DAG.getConstant(0xffff, MVT::i32);                                                                                                                                                                                           </div>
<div>    DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 0), LdResult);</div><div>    DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 1), Chain);</div><div>    DAG.RemoveDeadNode(LD);</div><div>    return DAG.getNode(ISD::AND, dl, MVT::i32, LdResult, Mask);                                                                                                                                                                                    </div>
<div> }</div><div style> else </div><div style>      return Op;</div><div>}</div><div><br></div><div style>However, when I get the following error during the compilation of the test file. </div><div style><br></div><div style>
<div>llc: /files3/scratch/gho705/llvm/llvm-3.2.src/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:694: bool llvm::SelectionDAG::RemoveNodeFromCSEMaps(llvm::SDNode*): Assertion `N->getOpcode() != ISD::DELETED_NODE && "DELETED_NODE in CSEMap!"' failed.</div>
<div><br></div><div style>I am wondering what was wrong with the way I removed the current illegal extending load?</div><div style><br></div><div style>Thank you,</div><div style><br></div><div style>Giang</div><div><br></div>
</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 4, 2013 at 3:14 PM, Giang Hoang <span dir="ltr"><<a href="mailto:ghoang84@gmail.com" target="_blank">ghoang84@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>For my research, I need to reshape the current ARM backend to support armv2a.  Zero-extend half word load (ldrh) is not supported by armv2a, so I need to make the code generation to not generate ldrh instructions.  I want to replace all those instances with a 32-bit load (ldr) and then and the result with 0xffff to mask out the upper bits.</div>

<div><br></div><div>These are the modifications that I have made to accomplish that:</div><div><br></div><div>1.  Register the ZEXTLOAD for custom lowering:</div><div><br></div><div>setLoadExtAction(ISD::ZEXTLOAD, MVT::i16, Custom); <br>

</div><div><br></div><div>2.  Implement a custom lowering function:</div><div><br></div><div><div>static SDValue LowerExtLoad(SDValue Op, SelectionDAG &DAG) {</div><div>  LoadSDNode *LD = dyn_cast<LoadSDNode>(Op.getNode());</div>

<div>  ISD::LoadExtType ExtType = LD->getExtensionType();</div><div>  </div><div>  if (LD->getExtensionType() == ISD::ZEXTLOAD) {</div><div>    DEBUG(errs() << "ZEXTLOAD\n");</div><div>    SDValue Chain = LD->getChain();</div>

<div>    SDValue Ptr = LD->getBasePtr();</div><div>    DebugLoc dl = Op.getNode()->getDebugLoc();</div><div>    SDValue LdResult = DAG.getExtLoad(ISD::EXTLOAD, dl, MVT::i32,</div><div>                                      Chain, Ptr, LD->getPointerInfo(), MVT::i32,</div>

<div>                                      LD->isVolatile(), LD->isNonTemporal(),</div><div>                                      LD->getAlignment());</div><div>    Chain = LdResult.getValue(1);</div><div>    SDValue Mask = DAG.getConstant(0x1, MVT::i32);                                                                                                                                                                                           </div>

<div>    DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 0), LdResult);</div><div>    DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 1), Chain);</div><div><div>    DAG.RemoveDeadNode(LD);</div><div>    //return DAG.getNode(ISD::AND, dl, MVT::i32, Op, Mask);                                                                                                                                                                                    </div>

<div> }</div><div>   <br>}</div></div><div><br></div><div><br></div></div></div>
</blockquote></div><br></div>