Bill Allombert on Tue, 03 Oct 2023 16:47:50 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: constant expressions
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Tue, 3 Oct 2023 16:47:47 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1696344458; c=relaxed/relaxed; bh=tJUbzOjag+PUrCw334qw0Q7lYb8MQiqbz86OqtqUGZk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=RuaptnEaJ8y49rN4roCBxWSeyNWlNunMNkayxNueemUzQkWaEy7QPnSIhhXkgfE2NEzmGjIQE1zVSTYTWc6lg6H00deaH5u8/pXDeEh6/P/PxCsgFSO578HSMgU6pt5tzEfjy6r/mNSGxrcprMHJg9fwnOQlwHUdVGpxP/X8HL0WfssRfeUgINTMemxS8VzWZUwmLPsdMnpUHx+A8EfEmE5sO8pssbHCp8kOJVrF8es2CZDTHbl80pREly1M+MlKa722+TMzfbI7YhJV8mBCZXmIsFuriv0ZQrv5RJpDCXPJ5yQC32uqvaGSHYx4FquTgeiWXvhPBf32sD3C4csxp7ZCkuM2yK15OihIr6fxsRItHNN3W0JATB3yg6hO+AkrBQ6h5ZS5zoizh7plKPPkBglwXOd5vXAHkW3INSzXMTt9O2mivdPvj0RzXyGA2fjZncrY6ZzH2OjHehDMQ/9g+lfBeWqzkUevgPmwHApwwCsoMkWHZViODZsTM2ib+2LcZ0j8WcSu1evkROTlYL1gZDx7znpCQizBYnP7OR2am4F4Kks5QGDsbnv24jFf+EO2icG3gPnsSN60CmhO/HSRk5XDmC7+nyngeSQbqe7tQZ1Jaih3HflgX4/2DSLQ82ZFUie8d5daZBMPtm2RdjNOMKz2JF9cp0viVyDiEyfN/Ys=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1696344458; cv=none; b=uwBEGBGHNreRwwWfFsTXVpDuLBfxxi27jzC+VTvZEAVeaFHrjt0O5sLAWZK7iasIZv0u+ReInemnqqvsJSy93bV+0Oth6JQmWaxFRTzHqboC7pvZzTlZm42MGhpHTDcVU0ub26vibMVqusP+H/Z8Q5+6pG/2whEs0aI7Tb+A6N3JXS6nEuHLabT76TjpeySuwrzWdlEIpNNe37ykAw3iJhyPbuBgEt/eSUuB84WZoiNcWpcRLJw98iQrt7jb2Yij23nOy3nGRBWxkFOgTBPae3MJ2AhtCjzM9NF+wYVbx+eiWd3HroovN1jSzALlVqLrnNUhaSrCnYOlU3BjtxDsG2tsQaKyY4jjLNzASwjGGW8aatEGsOB4CKiKtlWglgO22UKvqyK34hkDWsyAGguLeMwdk1+oEjb5/POdESFODmnl5fPnDT1Jrdp3s9EhfxKd6lWPIJo0PojIinHIkRmr7zGQ0bZ2L2pLXitO3rZamMKI0kQGvlw9NcinqCUxknI5lUNPhp/ark9lXQ0I/oIRSaqwXiZo9J3M+QWBSC0JnnoMd8mai7gC1cjQvR2eLRACTHX9ORfygiOtPxWqvZ5HHD3qAv621vph1EYonwm/gswavb0XBfw2kzrtWLK+Gt6MQNv+keOs0xeQ2xELC3MwXOokJwHn+oxiVlcgnysCu0g=
- Authentication-results: smail; arc=none
- Delivery-date: Tue, 03 Oct 2023 16:47:50 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1696344458; bh=tJUbzOjag+PUrCw334qw0Q7lYb8MQiqbz86OqtqUGZk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=ufxPGdmyQAczrghvSi71M/KD0qAZxj1a1+tOjBcFQYA6rT1TzmTZhLGA9sS0d03Ls IwzHjEU1ZN9l8GIqGqwpE7LDeR678QBJJfC9DImrtgmr4YMPqGQQ1cStx67D3oWer2 K1gcjCYJVcxxroZhuIwfbUa7ltpphx/orqRb0sbkz6XzqXPR7Q8z+yrBHZmwt1+jaq IxYf9B9UYl+HUFGta8Nu/zTQjQ0RJq6x9ahl8PXzX4UbZXxmD3iVpTSp1gOu+bm8zp B6hp8t80NqITz47xZDsqc4YHNUqsVWAbnAuwA4jSbd4GYZb6GDg3Eo1bgRw2YrZ2QX mprSvZVyYexl9TvjLpxYgjZBMvLkheovN5C10Z3UAwdL4bESoN1oQ15a8HAJis/6by 7BW0NYZ35fJ4QaWN3GBkCBlJ9cNIb0nS3HUSgZZS6nm2IjjrX2zKKBSt4H7+MODe3l m04gR1q7HZgBNmULW/hayU22fKbcMmIymuxFlZcTLdGENhT/ixE8gVafoXnARkfSrx QHu7+oAyrycaHojaWbRkXxHZeZKCXmJvO0PwDZQgnqUR6uWm5Fy1n2VGoKwKIkFRm+ Rg3lvd8ORKWdcBVAEvFf9vjlWWHhkDnyQlwnBqEWehUZ1l3mSeSIe/KCqu5mpzRWKf sd8S5aZHLSOmIwLP4I3Imjlk=
- In-reply-to: <124d7bf3-2c65-41d9-b983-91c88c89529e@isolution.nl>
- Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
- References: <124d7bf3-2c65-41d9-b983-91c88c89529e@isolution.nl>
On Tue, Oct 03, 2023 at 02:54:43PM +0200, Ruud H.G. van Tol wrote:
>
> Beware, "academic" examples only:
>
> ? for( i=1, 1e6, )
> cpu time = 85 ms, real time = 87 ms.
>
> ? for( i=1, 1e6, 0 )
> cpu time = 97 ms, real time = 98 ms.
>
> ? for( i=1, 1e6, 0+0+0+0+0+0+0 )
> cpu time = 312 ms, real time = 313 ms.
>
> ? for( i=1, 1e6, 1 )
> cpu time = 104 ms, real time = 105 ms.
>
> ? for( i=1, 1e6, 1/1/1/1/1/1/1 )
> cpu time = 465 ms, real time = 419 ms.
>
> Would it be feasible, and useful, and doable,
> to make PARI/GP optimize constant expressions?
The compiler is written with the purpose to do what the user asks.
If you write 0+0+0+0+0+0+0 instead of 0 you probably have your reason and
the compiler should respect that.
For example
? for( i=1, 10^7, 1+0 )
? ##
*** last result: cpu time 429 ms, real time 429 ms.
? for( i=1, 10^7, 0+1 )
? ##
*** last result: cpu time 445 ms, real time 445 ms.
With constant folding, we would not be able to observe that!
Cheers,
Bill.