https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117253
Bug ID: 117253
Summary: [14/15 regression] Generated code at -Os on trunk is
larger than GCC 13.3
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: dccitaliano at gmail dot com
Target Milestone: ---
https://gcc.godbolt.org/z/cqvMzPd4d
Inline code:
int f(int a) {
int* ptr = &a;
int result = *ptr;
int* arr = new int[10];
for (int i = 0; i < 10; i++) {
arr[i] = i;
}
union Data {
int i;
float f;
} data;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if ((i + j) % 3 == 0 && (i * j) % 2 != 0) {
if ((i * j) > 20 && (i + j) < 15) {
result += i * j;
}
result += i + j;
*ptr += arr[i] + arr[j];
data.i = i + j;
data.f = (float)data.i / 2.0f;
result += data.i;
for (int k = 0; k < 5; k++) {
if ((k * i) % 4 == 0 && (j * k) % 5 != 0) {
result += k * i * j;
}
}
}
}
}
delete[] arr;
return result;
}
This points to:
commit 55fcaa9a8bd9c8ce97ca929fc902c88cf92786a0
Author: Andrew Pinski <[email protected]>
Date: Wed Jun 7 09:05:15 2023 -0700
Add Plus to the op list of `(zero_one == 0) ? y : z <op> y` pattern
This adds plus to the op list of `(zero_one == 0) ? y : z <op> y` patterns
which currently has bit_ior and bit_xor.
This shows up now in GCC after the boolization work that Uroš has been
doing.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/97711
PR tree-optimization/110155
gcc/ChangeLog:
* match.pd ((zero_one == 0) ? y : z <op> y): Add plus to the op.
((zero_one != 0) ? z <op> y : y): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/branchless-cond-add-2.c: New test.
* gcc.dg/tree-ssa/branchless-cond-add.c: New test.
gcc/match.pd | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add-2.c | 8 ++++++++
gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add.c | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add-2.c
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add.c