[PATCH] match: Change (A + CST0) * CST1 to (A + sign_extend(CST0)) * CST1 [PR116845]

2024-12-31 Thread Konstantinos Eleftheriou
From: kelefth `(A * B) + (-C) to (B - C/A) * A` fails to match on ILP32 targets due to the upper bits of CST0 being zeros in some cases. This patch adds the following pattern in match.pd: (A + CST0) * CST1 -> (A + CST0') * CST1, where CST1 is a power of 2 constant and CST0' is CST0 with the log2

[PATCH] avoid-store-forwarding: Fix base register initialization when eliminating loads [PR117835]

2024-12-17 Thread Konstantinos Eleftheriou
From: kelefth During the initialization of the base register for the zero-offset store, in the case that we are eliminating the load, we used a paradoxical subreg assuming that we don't care about the higher bits of the register. This led to writing wrong values when we were not updating the whol

[PATCH] avoid-store-forwarding: Reject changes when an instruction may throw [PR117816]

2024-12-05 Thread Konstantinos Eleftheriou
From: kelefth Avoid-store-forwarding doesn't handle the case where an instruction in the store-load sequence contains a REG_EH_REGION note, leading to the insertion of instructions after it, while it should be the last instruction in the basic block. This causes an ICE when compiling using `-O -f

Re: [PATCH v7] Target-independent store forwarding avoidance.

2024-11-09 Thread Konstantinos Eleftheriou
.html). Thanks, Konstantinos. On Sat, Oct 26, 2024 at 5:54 PM Jeff Law wrote: > > > > On 10/23/24 8:27 AM, Konstantinos Eleftheriou wrote: > > From: kelefth > > > > This pass detects cases of expensive store forwarding and tries to avoid > > them > >

[PATCH v8] Target-independent store forwarding avoidance.

2024-11-09 Thread Konstantinos Eleftheriou
Signed-off-by: Konstantinos Eleftheriou Series-version: 8 Series-changes: 8 - Fix store_bit_field call for big-endian targets, where BITS_BIG_ENDIAN is false. - Handle store_forwarding_max_distance = 0 as a special case that disables cost checks for avoid-store

Re: [PATCH v6] Target-independent store forwarding avoidance.

2024-10-23 Thread Konstantinos Eleftheriou
0/18/24 3:57 AM, Konstantinos Eleftheriou wrote: > > From: kelefth > > > > This pass detects cases of expensive store forwarding and tries to avoid > > them > > by reordering the stores and using suitable bit insertion sequences. > > For example it can

[PATCH v7] Target-independent store forwarding avoidance.

2024-10-23 Thread Konstantinos Eleftheriou
-store-forwarding-3.c: New test. * gcc.target/aarch64/avoid-store-forwarding-4.c: New test (XFAIL). * gcc.target/aarch64/avoid-store-forwarding-5.c: New test (XFAIL). Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou Series-version: 7 Series-changes: 7

[PATCH v6] Target-independent store forwarding avoidance.

2024-10-18 Thread Konstantinos Eleftheriou
-store-forwarding-3.c: New test. * gcc.target/aarch64/avoid-store-forwarding-4.c: New test (XFAIL). * gcc.target/aarch64/avoid-store-forwarding-5.c: New test (XFAIL). Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou Series-version: 6 Series-changes: 6

Re: [PATCH v5] Target-independent store forwarding avoidance.

2024-10-18 Thread Konstantinos Eleftheriou
Sent a new version for this in https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665794.html. Thanks, Konstantinos. On Fri, Aug 30, 2024 at 4:32 PM Richard Sandiford wrote: > > Manolis Tsamis writes: > >> > I could have some help with that, because after the new changes a > >> > subreg rel

[PATCH v4] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-09-19 Thread Konstantinos Eleftheriou
-xor-and-or.c: New test. * gcc.dg/tree-ssa/fold-xor-or.c: New test. Tested-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou --- gcc/match.pd | 32 ++- .../gcc.dg/tree-ssa/fold-xor-and

Re: [PATCH v3] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-09-19 Thread Konstantinos Eleftheriou
I have sent a new version (https://gcc.gnu.org/pipermail/gcc-patches/2024-September/663350.html). I also added :c to the ne operations. Thanks, Konstantinos On Wed, Sep 18, 2024 at 1:52 PM Richard Biener wrote: > > On Wed, Sep 18, 2024 at 10:42 AM Konstantinos Eleftheriou > wrote: &

Re: [PATCH v3] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-09-18 Thread Konstantinos Eleftheriou
fold-xor-and-or.c: New test. > > * gcc.dg/tree-ssa/fold-xor-or.c: New test. > > > > Reviewed-by: Christoph Müllner > > Signed-off-by: Philipp Tomsich > > Signed-off-by: Konstantinos Eleftheriou > > --- > > gcc/match.pd

Re: [PATCH] match: Change (A * B) + (-C) to (B - C/A) * A, if C multiple of A [PR109393]

2024-09-17 Thread Konstantinos Eleftheriou
regression tested on x86-64 and > aarch64. > > > > PR tree-optimization/109393 > > > > gcc/ChangeLog: > > > > * match.pd: (A * B) + (-C) -> (B - C/A) * A, if C a multiple of > A. > > > > gcc/testsuite/ChangeLog: > >

[PATCH v2] match: Change (A * B) + (-C) to (B - C/A) * A, if C multiple of A [PR109393]

2024-09-17 Thread Konstantinos Eleftheriou
. gcc/testsuite/ChangeLog: * gcc.dg/pr109393.c: New test. Tested-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou --- gcc/match.pd| 21 - gcc/testsuite/gcc.dg/pr109393.c | 23 +++ 2 files c

[PATCH] match: Change (A * B) + (-C) to (B - C/A) * A, if C multiple of A [PR109393]

2024-09-06 Thread konstantinos . eleftheriou
. gcc/testsuite/ChangeLog: * gcc.dg/pr109393.c: New test. Tested-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou --- gcc/match.pd| 15 ++- gcc/testsuite/gcc.dg/pr109393.c | 23 +++ 2 files chang

Re: [PATCH v2] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-08-29 Thread Konstantinos Eleftheriou
024 at 4:24 PM Konstantinos Eleftheriou > wrote: > > > > From: kelefth > > > > In expressions like (a != b || ((a ^ b) & CST0) == CST1) and > > (a != b || (a ^ b) == CST), (a ^ b) is folded to false. > > In the equivalent expressions (((a ^ b) & CST0)

[PATCH v3] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-08-29 Thread konstantinos . eleftheriou
and-or.c: New test. * gcc.dg/tree-ssa/fold-xor-or.c: New test. Reviewed-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-off-by: Konstantinos Eleftheriou --- gcc/match.pd | 30 ++ .../gcc.dg/tree-ssa/fold-xor-and

Re: [PATCH] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-08-16 Thread Konstantinos Eleftheriou
Thanks, fixed ( https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660631.html). On Thu, Aug 15, 2024 at 3:57 PM Sam James wrote: > Konstantinos Eleftheriou writes: > > > From: kelefth > > > > In expressions like (a != b || ((a ^ b) & CST0) == CST1) and > &

[PATCH v2] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-08-16 Thread Konstantinos Eleftheriou
estsuite/ChangeLog: * gcc.dg/tree-ssa/fold-xor-and-or-1.c: New test. * gcc.dg/tree-ssa/fold-xor-and-or-2.c: New test. * gcc.dg/tree-ssa/fold-xor-or-1.c: New test. * gcc.dg/tree-ssa/fold-xor-or-2.c: New test. Reviewed-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-of

[PATCH] match: Fix A || B not optimized to true when !B implies A [PR114326]

2024-08-14 Thread Konstantinos Eleftheriou
estsuite/ChangeLog: * gcc.dg/tree-ssa/fold-xor-and-or-1.c: New test. * gcc.dg/tree-ssa/fold-xor-and-or-2.c: New test. * gcc.dg/tree-ssa/fold-xor-or-1.c: New test. * gcc.dg/tree-ssa/fold-xor-or-2.c: New test. Reviewed-by: Christoph Müllner Signed-off-by: Philipp Tomsich Signed-of