https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118727
--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #4) > My patch does not work for a slightly twisted test case: > > /* { dg-do run } */ > /* { dg-options "-O2 -ftree-vectorize" } */ > > __attribute__((noipa)) int > foo (signed char *x, signed char *y, int n) > { > int i, r = 0; > signed char a, b; > for (i = 0; i < n; i++) > { > a = x[i]; > b = y[i]; > int c = (unsigned int)(unsigned char) a - (signed int)(signed char) b; > r = r + (c < 0 ? -c : c); > } > return r; > } /* snip */ With this one, // signed_char a_14, b_16; a.0_4 = (unsigned char) a_14; _5 = (unsigned int) a.0_4; _6 = (unsigned int) b_16; _7 = _5 - _6; c_17 = (int) _7; _8 = ABS_EXPR <c_17>; becomes: patt_28 = (unsigned short) a.0_4; patt_25 = (signed short) b_16; patt_26 = (signed short) patt_28; patt_20 = .ABD (patt_26, patt_25); It's still correct, but then patt_40 = (signed char) a.0_4; patt_41 = SAD_EXPR <patt_40, b_16, r_23>; is no longer correct. patt_41 = SAD_EXPR <patt_40, b_16, r_23>;