https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111779
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c |tree-optimization Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |jamborm at gcc dot gnu.org Last reconfirmed| |2023-10-12 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The issue is the aggregate copy: t.c:26:22: missed: not vectorized: more than one data ref in stmt: a = *_3; which SRA fails to scalarize: <bb 3> [local count: 955630224]: # s_23 = PHI <s_18(3), 0(2)> # i_25 = PHI <i_20(3), 0(2)> _1 = (long unsigned int) i_25; _2 = _1 * 24; _3 = x_16(D) + _2; a = *_3; _4 = BIT_FIELD_REF <a.b4, 8, 64>; _12 = _4 & 1; _6 = (int) _12; s_18 = _6 + s_23; a ={v} {CLOBBER(eol)}; i_20 = i_25 + 1; if (y_14(D) > i_20) Candidate (2778): a ... ! Disqualifying a - No scalar replacements to be created. the BIT_FIELD_REF is already created by early folding in optimize_bit_field_compare folding (int) a.b4.f != 0 s = ((int) NON_LVALUE_EXPR <BIT_FIELD_REF <a.b4, 8, 64>> & 1) + s; SRA could handle BIT_FIELD_REFs just fine - esp. quantities with a byte size. And then this folding is just premature... Removing the folding that handles BF != CST fixes it. I know removing all of it, esp. BF != BF will regress some stuff. I'll put this half-way patch through testing. diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 82299bb7f1d..3db383360d6 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -4695,7 +4695,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, return 0; if (const_p) - rreversep = lreversep; + return 0; else { /* If this is not a constant, we can only do something if bit positions,