Commit fd85a6c6 authored by Dmitry Vyukov's avatar Dmitry Vyukov

cmd/gc: fix condition for fast pathed interface conversions

For some reason the current conditions require the type to be "uintptr-shaped".
This cuts off structs and arrays with a pointer.
isdirectiface and width==widthptr is sufficient condition to enable the fast paths.

Change-Id: I11842531e7941365413606cfd6c34c202aa14786
Reviewed-on: https://go-review.googlesource.com/3414Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent b581ca59
...@@ -883,8 +883,8 @@ walkexpr(Node **np, NodeList **init) ...@@ -883,8 +883,8 @@ walkexpr(Node **np, NodeList **init)
case OCONVIFACE: case OCONVIFACE:
walkexpr(&n->left, init); walkexpr(&n->left, init);
// Optimize convT2E as a two-word copy when T is uintptr-shaped. // Optimize convT2E as a two-word copy when T is pointer-shaped.
if(isnilinter(n->type) && isdirectiface(n->left->type) && n->left->type->width == widthptr && isint[simsimtype(n->left->type)]) { if(isnilinter(n->type) && isdirectiface(n->left->type)) {
l = nod(OEFACE, typename(n->left->type), n->left); l = nod(OEFACE, typename(n->left->type), n->left);
l->type = n->type; l->type = n->type;
l->typecheck = n->typecheck; l->typecheck = n->typecheck;
...@@ -927,7 +927,7 @@ walkexpr(Node **np, NodeList **init) ...@@ -927,7 +927,7 @@ walkexpr(Node **np, NodeList **init)
l->addable = 1; l->addable = 1;
ll = list(ll, l); ll = list(ll, l);
if(isdirectiface(n->left->type) && n->left->type->width == widthptr && isint[simsimtype(n->left->type)]) { if(isdirectiface(n->left->type)) {
/* For pointer types, we can make a special form of optimization /* For pointer types, we can make a special form of optimization
* *
* These statements are put onto the expression init list: * These statements are put onto the expression init list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment