https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122478
Bug ID: 122478
Summary: [16 Regression] Recent match.pd change breaks gimple
checking
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: law at gcc dot gnu.org
Target Milestone: ---
This change:
commit 5eafa8d16be87339acd11446283c571b2416a532 (HEAD)
Author: Artemiy Volkov <[email protected]>
Date: Mon Oct 27 14:47:31 2025 +0000
match.pd: simplify (view_convert (BIT_FIELD_REF))
This patch adds a match.pd transformation to strip unnecessary
view_converts of BIT_FIELD_REFs. This is only valid when the type of the
view_convert is a register type, and no loss of precision is involved when
casting to an integer type; both of these conditions are checked for in
the if clause of the new pattern.
The change survives bootstrap + regtest on aarch64 and x86_64, and one
additional test case has been added to gcc.dg/tree-ssa.
Changes since v1:
- Require is_gimple_reg_type (type) and remove conditions on @0
- Reword the commit message to reflect code changes
gcc/ChangeLog:
* match.pd: Add pattern to simplify view_convert (BIT_FIELD_REF).
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/forwprop-42.c: New test.
Tests that now fail, but worked before (1 tests):
unix//-march=rv32gcv: gcc: gcc.target/riscv/rvv/autovec/pr114668.c -O3
-ftree-vectorize (test for excess errors)
In the log file we see:
Excess errors:
/home/jlaw/test/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr114668.c:18:5:
error: integral result type precision does not match field size of
'bit_field_ref'
_180 = BIT_FIELD_REF <mask__701.18_30, 1, 12>;
during GIMPLE pass: forwprop
You should be able to see this with a cross compiler, so you don't need a full
testing setup. Compile the attached test with:
-O3 -march=rv32gcv -fno-vect-cost-model
char a;
int b;
short e[14];
char f[4][12544];
_Bool c[4][5];
__attribute__ ((noipa))
void foo (int a)
{
if (a != 1)
__builtin_abort ();
}
int main ()
{
for (int i = 0; i < 4; ++i)
for (int l = 0; l < 15; ++l)
for (int m = 0; m < 15; ++m)
f[i][l * m] = 3;
for (int j = 0; j < 4; j += 1)
for (int k = 3; k < 13; k += 3)
for (_Bool l = 0; l < 1; l = 1)
for (int m = 0; m < 4; m += 1)
{
a = 0;
b -= e[k];
c[j][m] = f[j][6];
}
for (long i = 2; i < 4; ++i)
foo (c[3][3]);
}