Subsuming a memory node of a TargetGlobalAddress with a TargetConstant node

I am trying to removing a load to a TargetGlobalAddress in ISelDagToDag that my backend does not support. The TargetGlobalAddress is assumed to always be of ConstantInt or ConstantFP type, so this transformation is valid. I am correctly able to modify the dag and remove all of the uses of the node as specified in the attached before and after dot images. The nodes in question is the CUSTOM_ADD_i32(0x002EDE80) → load(0x002EDAC8), but I am not able to figure out how to correctly modify the chain and point the TokenFactor(0x002EDBD8) node to the llvm.opencl.other.get.global.id(0x002ED3E0) node so that I can completely remove the load, undef, and targetglobaladdress nodes.

If anyone can give me any hints on how I can do this, it would be greatly appreciated. I am already creating a target specific constant and then using DAG->ReplaceAllUsesOfValueWith(Op, SDValue(N, 0)) to remove the first connect, but I’m not sure how to remove the chain.

Thanks for your time,

Micah

before.dot (9.51 KB)

after.dot (9.51 KB)

Villmow, Micah wrote:

I am trying to removing a load to a TargetGlobalAddress in ISelDagToDag that my backend does not support. The TargetGlobalAddress is assumed to always be of ConstantInt or ConstantFP type, so this transformation is valid. I am correctly able to modify the dag and remove all of the uses of the node as specified in the attached before and after dot images. The nodes in question is the CUSTOM_ADD_i32(0x002EDE80) -> load(0x002EDAC8), but I am not able to figure out how to correctly modify the chain and point the TokenFactor(0x002EDBD8) node to the llvm.opencl.other.get.global.id(0x002ED3E0) node so that I can completely remove the load, undef, and targetglobaladdress nodes.

If anyone can give me any hints on how I can do this, it would be greatly appreciated. I am already creating a target specific constant and then using DAG->ReplaceAllUsesOfValueWith(Op, SDValue(N, 0)) to remove the first connect, but I’m not sure how to remove the chain.

Thanks for your time,

Micah

A load takes a chain as input and produces a chain as output. While removing the load node you can retrieve the incoming chain to load and put it where the out chain of load goes to.

In PIC16 backend, we replace "load" with pic16 specific load node called "PIC16Load". See if PIC16 code can help.

- Sanjiv