Question regarding ReplaceValueWith and ReplaceNodeResults

Hi,

I am defining Hexagons version of ReplaceNodeResults to change the a node of
the type

To
B: SIGN_EXTEND (A)

After returning from my function, the type legalizer calss
ReplaceValuesUsesWith to replace the uses of A with B. Unfortunately, it
replaces the use of A in the new node B too. So the node now is
B: SIGN_EXTEND(B) , which is clearly bad and the compiler crashes.

In the backend, I tried to create a whole new A, say A` using the operands
of A. That didn’t work either, because DAG.getNode(INTRINSIC_WO_CHAIN, .. ,
.., operands of A) returned a memorized version of A itself leading to the
same problem.

FWIW, ReplaceNodeResults returns new nodes (B in this case) in a vector. Is
there something wrong I am doing vis-à-vis the expectations of the
SelectionDAG from the backend ?

TIA,
Pranav
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

The type legalizer asked your target to replace an node with an
illegal type with a node with a legal type, and your target returned a
use of the illegal node. This makes no sense.

-Eli

The type legalizer asked your target to replace an node with an illegal

type

with a node with a legal type, and your target returned a use of the

illegal

node. This makes no sense.

Aargh, thanks. I did not think of that at all. I confused type legalization
with promotion by sign-extension.

Thanks,
Pranav

Hi Pranav,

I am defining Hexagons version of ReplaceNodeResults to change the a node of
the type
A: i8 = INTRINSIC_WO_CHAIN ... , ... ,

To
B: SIGN_EXTEND (A)

as well as what Eli said, ReplaceNodeResults requires (IIRC) the new node to
have the same type as the old node, which doesn't seem to be the case here.

Ciao, Duncan.