>>>> + if (TREE_TYPE (TREE_TYPE (src_ptr)) != src_type) >>> >>> This line looks unexpected, the former is type char while the latter is >>> type __vector_pair *. >>> >>> I guess you meant to compare the type of pointer type like: >>> >>> TREE_TYPE (TREE_TYPE (src_ptr)) != TREE_TYPE (src_type) >> >> Maybe? However, if that is the case, how can it be working for me? >> Let me throw this in the debugger and verify the types and I'll report >> back with what I find. > > Ok, you are correct. Thanks for catching that! I don't think we need > those matching outer TREE_TYPE() uses. I think just a simple: > > if (TREE_TYPE (src_ptr) != src_type) > > ...should suffice. >
Yeah, it's enough for the associated test case. :) > >>> or even with mode like: >>> >>> TYPE_MODE (TREE_TYPE (TREE_TYPE (src_ptr))) != TYPE_MODE (TREE_TYPE >>> (src_type)) > > I'd rather not look at the mode here, since OOmode/XOmode doesn't necessarily > mean __vector_{pair,quad}, so I'll go with the modified test above. Good point. I thought the cv qualifier can affect the type equality check and assumed for test case like: void foo (char *resp, const __vector_pair *vpp) { __builtin_vsx_disassemble_pair (resp, (__vector_pair *) vpp); } , we don't want to have the conversion there and the ICE seems related to the underlying mode, so I thought maybe you wanted to use TYPE_MODE. >>>> + src_ptr = build1 (VIEW_CONVERT_EXPR, src_type, src_ptr); >>> >>> Nit: NOP_EXPR seems to be better suited here for pointer conversion. > > Ok, this works too, so code changed to use it. Thanks! > > Question for my own education, when would you use VIEW_CONVERT_EXPR over > NOP_EXPR? tree.def has some note about VIEW_CONVERT_EXPR, it quite matches what Segher replied. In my experience, VIEW_CONVERT_EXPR are used a lot for vector type conversion. BR, Kewen