Re: [EXTERNAL] Re: [PATCH] Propagate get_nonzero_bits information in division [PR77980]

2021-08-30 Thread Victor Tong via Gcc-patches
gnu.org ; pins...@gcc.gnu.org Subject: [EXTERNAL] Re: [PATCH] Propagate get_nonzero_bits information in division [PR77980]   On 7/26/2021 6:45 PM, Victor Tong via Gcc-patches wrote: > This change enables the "t1 != 0" check to be optimized away in this code: > > int x1 = 0; &

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-22 Thread Victor Tong via Gcc-patches
Thanks for the feedback. I updated the pattern and it passes all tests (existing and the new ones I wrote). I added some brackets since there were some warnings about missing brackets on the || and &&. Here's the updated pattern: (simplify (minus (convert1? @0) (convert2? (minus@2 (conver

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-08-06 Thread Victor Tong via Gcc-patches
Thanks for the feedback. Here's the updated pattern: /* X - (X - Y) --> Y */ (simplify (minus (convert1? @0) (convert2? (minus@2 (convert3? @@0) @1))) (if (ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_UNDEFINED(type) && !TYPE_OVERFLOW_SANITIZED(type) && ANY_INTEG

[PATCH] Propagate get_nonzero_bits information in division [PR77980]

2021-07-26 Thread Victor Tong via Gcc-patches
This change enables the "t1 != 0" check to be optimized away in this code: int x1 = 0; unsigned int x2 = 1; int main () { int t1 = x1*(1/(x2+x2)); if (t1 != 0) __builtin_abort(); return 0; } The change utilizes the VRP framework to propagate the get_nonzero_bits information from the

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-07-19 Thread Victor Tong via Gcc-patches
Gentle ping. From: Gcc-patches on behalf of Victor Tong via Gcc-patches Sent: Monday, June 28, 2021 4:10 PM To: Richard Biener ; Marc Glisse Cc: gcc-patches@gcc.gnu.org Subject: Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-28 Thread Victor Tong via Gcc-patches
​Thanks Richard and Marc. I wrote the following test case to compare the outputs of fn1() and fn1NoOpt() below with my extra pattern being applied. I tested the two functions with all of the integers from INT_MIN to INT_MAX. long fn1 (int x) {   return 42L - (long)(42 - x); } #pragma GCC push_

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-16 Thread Victor Tong via Gcc-patches
? Richard. > Thanks, > Victor > > > From: Richard Biener > Sent: Tuesday, April 27, 2021 1:29 AM > To: Victor Tong > Cc: gcc-patches@gcc.gnu.org > Subject: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed > by multiply [PR95176] > > On

Re: [EXTERNAL] Re: [PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-06-02 Thread Victor Tong via Gcc-patches
n followed by multiply [PR95176]   On Thu, Apr 1, 2021 at 1:03 AM Victor Tong via Gcc-patches wrote: > > Hello, > > This patch fixes PR tree-optimization/95176. A new pattern in match.pd was > added to transform "a * (b / a)" --> "b - (b % a)". A new test

Patch ping for PR95176 fix

2021-04-12 Thread Victor Tong via Gcc-patches
Hello, I'd like to ping this patch. It contains two new tree-opt patterns in match.pd. [PATCH] tree-optimization: Optimize division followed by multiply [PR95176] (gnu.org) Thanks, Victor

[PATCH] tree-optimization: Optimize division followed by multiply [PR95176]

2021-03-31 Thread Victor Tong via Gcc-patches
Hello, This patch fixes PR tree-optimization/95176. A new pattern in match.pd was added to transform "a * (b / a)" --> "b - (b % a)". A new test case was also added to cover this scenario. The new pattern interfered with the existing pattern of "X - (X / Y) * Y". In some cases (such as in fn4(