From patchwork Thu Jun 14 00:47:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 164777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BD57DB7028 for ; Thu, 14 Jun 2012 10:48:04 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340239686; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=u8HOhmkSR+2dIYBUPTYDKO9O5e8=; b=GJicilwRpDr+THA wXJdArgzdyuYhdGSvAiUGtqD/8O4yrHlV6udJp3SvjhYnyhj9Qu60DljS7kE93t4 TtdJusiGZ4+sZmBjZ/PWX4brwBRpk300WQn6ETP6jL9dD0sabBOPRpNrAJR1hvth 1R8T2nAjoT8IlS+0wUC+IW4eTBcY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=IbVvbTvXrpT5+a7rDA7h/97h+oufpS4UDq0d545sQ3FgoOV0pFY+Cj6ZY7joXF 1j2ka7ZeiA4ICBOUeljRiksQMft/WhlrADlvzFj8RXsCcp6YE8ycXqbyqHwdRSZO 2AnM9o4ngBV59hscW+cnVcGhj1uHErF7SWkUwOOWVdLdg=; Received: (qmail 4408 invoked by alias); 14 Jun 2012 00:47:59 -0000 Received: (qmail 4395 invoked by uid 22791); 14 Jun 2012 00:47:57 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jun 2012 00:47:44 +0000 Received: by pbbrq2 with SMTP id rq2so3005217pbb.20 for ; Wed, 13 Jun 2012 17:47:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=ysmdKCk1XdlWGAQPvfSvgT+l3gBm12NT/PokzZ5sgbo=; b=JopMeJ2oolDjyOuwsr2hlEYmpM7+974qncYrbOjw/OjAtJYAiSBCE0uyLN7PVyEz+W oFuB8BpZdX+g/tR+Xxsa+NeuzplqtzlXT9of7UbmMVbCy4LLE6YjvoNS3ZO/UvJnxO2m punGe2mOvzE+my10M3SLQdHGWX8mgDjsahMbIH6y9U49A1FgU1TBJW4I/OBF+q2IBKGl SHc4Zlde3DVm+sChSxcPQdQfC6HR0sFWE2D6XpUVzR0jafJV779zkKPu9K105g1wLQvZ QYZ9iKwjc+bW94lf4slOxZh1UcUtPZTC43aPDVEIYwGVAwy0V1HbxzhfmoT6AIOtyHVl Lbmw== Received: by 10.68.202.99 with SMTP id kh3mr1298883pbc.157.1339634864238; Wed, 13 Jun 2012 17:47:44 -0700 (PDT) Received: by 10.68.202.99 with SMTP id kh3mr1298874pbc.157.1339634864171; Wed, 13 Jun 2012 17:47:44 -0700 (PDT) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id rj4sm7505350pbc.30.2012.06.13.17.47.43 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Jun 2012 17:47:43 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Avoid some unnecessary interface conversions Date: Wed, 13 Jun 2012 17:47:42 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn+eWRQ3R/oDVWtLmY3UTsljqJl46hH8Yn0zMTHJ0m94G1q19izo+DrISjS7wnEHeDlBCVsy2G9s1LSxFEC7VNzyqQRksbrocEQmgt3NHou/6dGL9qMFIJuO5EDvFWBKYHCJDT8Md5nbJb07RoZ9juh3fj5tQ== X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch to the Go compiler avoids some unnecessary interface conversions. I was comparing Type* pointers for equality, but that only works if the types were defined before the code being compiled. If they were defined afterward, the types will normally be forward declarations. They will wind up pointing to the same type, but the pointers won't be equal. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 43610a429d23 go/expressions.cc --- a/go/expressions.cc Tue Jun 12 22:54:42 2012 -0700 +++ b/go/expressions.cc Wed Jun 13 17:37:20 2012 -0700 @@ -168,7 +168,8 @@ if (lhs_type_tree == error_mark_node) return error_mark_node; - if (lhs_type != rhs_type && lhs_type->interface_type() != NULL) + if (lhs_type->forwarded() != rhs_type->forwarded() + && lhs_type->interface_type() != NULL) { if (rhs_type->interface_type() == NULL) return Expression::convert_type_to_interface(context, lhs_type, @@ -179,7 +180,8 @@ rhs_type, rhs_tree, false, location); } - else if (lhs_type != rhs_type && rhs_type->interface_type() != NULL) + else if (lhs_type->forwarded() != rhs_type->forwarded() + && rhs_type->interface_type() != NULL) return Expression::convert_interface_to_type(context, lhs_type, rhs_type, rhs_tree, location); else if (lhs_type->is_slice_type() && rhs_type->is_nil_type())