{
tree fntype, idx, e1, delta, delta2, e2, e3, vtbl;
tree instance, basetype;
+ tree mask;
tree instance_ptr = *instance_ptrptr;
return instance;
e3 = PFN_FROM_PTRMEMFUNC (function);
-
+
vtbl = build1 (NOP_EXPR, build_pointer_type (ptr_type_node), instance);
TREE_CONSTANT (vtbl) = TREE_CONSTANT (instance);
to pointer-to-base-member, as long as the dynamic object
later has the right member. */
- /* Promoting idx before saving it improves performance on RISC
- targets. Without promoting, the first compare used
- load-with-sign-extend, while the second used normal load then
- shift to sign-extend. An optimizer flaw, perhaps, but it's
- easier to make this change. */
- idx = cp_build_binary_op (TRUNC_DIV_EXPR,
- build1 (NOP_EXPR, vtable_index_type, e3),
- TYPE_SIZE_UNIT (vtable_entry_type));
+ idx = build1 (NOP_EXPR, vtable_index_type, e3);
switch (TARGET_PTRMEMFUNC_VBIT_LOCATION)
{
case ptrmemfunc_vbit_in_pfn:
- e1 = cp_build_binary_op (BIT_AND_EXPR,
- build1 (NOP_EXPR, vtable_index_type, e3),
- integer_one_node);
+ /* Mask out the virtual bit from the index. */
+ e1 = cp_build_binary_op (BIT_AND_EXPR, idx, integer_one_node);
+ mask = build1 (NOP_EXPR, vtable_index_type, build_int_2 (~1, ~0));
+ idx = cp_build_binary_op (BIT_AND_EXPR, idx, mask);
break;
case ptrmemfunc_vbit_in_delta:
build_pointer_type (build_pointer_type (vtable_entry_type)),
vtbl, cp_convert (ptrdiff_type_node, delta2));
vtbl = build_indirect_ref (vtbl, NULL);
- e2 = build_array_ref (vtbl, idx);
+
+ e2 = fold (build (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, idx));
+ e2 = build_indirect_ref (e2, NULL);
/* When using function descriptors, the address of the
vtable entry is treated as a function pointer. */