From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31751 invoked by alias); 8 Oct 2010 13:14:52 -0000 Received: (qmail 31740 invoked by uid 22791); 8 Oct 2010 13:14:51 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.17.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 13:14:45 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.1/8.13.1) with ESMTP id o98DEghR029249 for ; Fri, 8 Oct 2010 13:14:42 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o98DEgDM4132956 for ; Fri, 8 Oct 2010 15:14:42 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o98DEgm6031249 for ; Fri, 8 Oct 2010 15:14:42 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id o98DEfAx031234; Fri, 8 Oct 2010 15:14:41 +0200 Message-Id: <201010081314.o98DEfAx031234@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 08 Oct 2010 15:14:41 +0200 Subject: Re: [patch] Scalar to vector widening To: ken@linux.vnet.ibm.com (Ken Werner) Date: Fri, 08 Oct 2010 13:14:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <201010072241.13455.ken@linux.vnet.ibm.com> from "Ken Werner" at Oct 07, 2010 10:41:13 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00134.txt.bz2 Ken Werner wrote: > @@ -2035,8 +2042,12 @@ evaluate_subexp_standard (struct type *e > > /* For shift and integer exponentiation operations, > only promote the first argument. */ > - if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP) > - && is_integral_type (value_type (arg2))) > + if (op == BINOP_LSH || op == BINOP_RSH) > + { > + arg2 = value_cast (check_typedef (value_type (arg1)), arg2); > + unop_promote (exp->language_defn, exp->gdbarch, &tmp); > + } I don't think these are quite right. If, say, arg2 is a vector of different type, this may get simply cast away. Likewise, if arg1 is a very short integer type, the cast may actually remove valid bits in arg2 ... I think the cast really should only be done if one side is a vector and the other a scalar. However, I don't quite like distributing the code between the various promotion routines. In fact, I'm starting to think this shouldn't actually be though of as a promotion at all. Instead, why not simply handle the case directly in vector_binop? If only one side is a vector and the other is a scalar, cast it there. This should simplify the patch even further. [ Note that value_binop already today performs type conversions (e.g. from integer to float). We only split off those performed by the GDB logic (value_binop) itself from those performed by language- specific promotion rules where the latter are ambiguous of change between languages. If value_binop gets called with a pair of a vector and a scalar, it ought to do *something* anyway, so we might as well decide the straight-forward widening is what happens. ] > +# Test scalar to vector widening > +gdb_test "print i4a + ib" "\\\$$decimal = \\{3, 5, 9, 17\\}" > +gdb_test "print fa - f4b" "\\\$$decimal = \\{1, 0, -6, -2\\}" > +gdb_test "print f4a * fb" "\\\$$decimal = \\{2, 4, 8, 16\\}" > +gdb_test "print ia / i4b" "\\\$$decimal = \\{2, 1, 0, 0\\}" > +gdb_test "print i4a % ib" "\\\$$decimal = \\{0, 0, 0, 0\\}" > + > +gdb_test "print ia & i4b" "\\\$$decimal = \\{0, 2, 0, 0\\}" > +gdb_test "print i4a | ib" "\\\$$decimal = \\{3, 5, 9, 17\\}" > +gdb_test "print ia ^ i4b" "\\\$$decimal = \\{3, 0, 10, 6\\}" > +gdb_test "print i4a << ib" "\\\$$decimal = \\{4, 8, 16, 32\\}" > +gdb_test "print i4a >> ib" "\\\$$decimal = \\{1, 2, 4, 8\\}" > + > +gdb_test "print i4b = ia" "\\\$$decimal = \\{2, 2, 2, 2\\}" > +gdb_test "print i4a = 3" "\\\$$decimal = \\{3, 3, 3, 3\\}" > +gdb_test "print f4a = fb" "\\\$$decimal = \\{1, 1, 1, 1\\}" > +gdb_test "print f4b = 2" "\\\$$decimal = \\{2, 2, 2, 2\\}" > + > +gdb_test "print i4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}" > +gdb_test "print i4a <<= ib" "\\\$$decimal = \\{4, 8, 16, 32\\}" Since we've now added support for casts, maybe a couple of tests for that capability would also be helpful. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com