https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116528
Bug ID: 116528 Summary: Not vectoring TSVC s318 loop Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kugan at gcc dot gnu.org Target Milestone: --- See: typedef float real_t; extern __attribute__((aligned(64))) real_t a[32000]; real_t not_woring(struct args_t *func_args) { int k, index; int inc = 1; real_t max, chksum; k = 0; index = 0; max = (a[0]); k += inc; for (int i = 1; i < 32000; i++) { if (a[k] > max) { index = i; max = (a[k]); } k += inc; } return max + index + 1; } Also in https://godbolt.org/z/ra4h6ndKz ifcvt dump is: <bb 3> [local count: 1063004408]: # k_16 = PHI <k_12(7), 1(15)> # index_17 = PHI <index_5(7), 0(15)> # max_19 = PHI <_29(7), max_10(15)> # ivtmp_15 = PHI <ivtmp_14(7), 31999(15)> _1 = a[k_16]; _13 = _1 > max_19; index_5 = _13 ? k_16 : index_17; _29 = MAX_EXPR <_1, max_19>; k_12 = k_16 + 1; ivtmp_14 = ivtmp_15 - 1; if (ivtmp_14 != 0) goto <bb 7>; [98.99%] else goto <bb 6>; [1.01%] <bb 7> [local count: 1052266995]: goto <bb 3>; [100.00%] <bb 16> [local count: 10737416]: Here PHI # max_19 = PHI <_29(7), max_10(15)> has two uses _29 = MAX_EXPR <_1, max_19>; and _13 = _1 > max_19; As a result, this is not a vect_is_simple_reduction. How can we support this?