https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96244
Bug ID: 96244 Summary: Redudant mask load generated Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- cat test.c --- typedef int v8si __attribute__ ((__vector_size__ (32))); v8si foo (v8si a, v8si b, v8si c, v8si d) { v8si e; for (int i = 0; i != 8; i++) e[i] = a[i] > b[i] ? c[i] : d[i]; return e; } --- gcc -Ofast -mavx2 test.c cat test.c.238t.optimized --- foo (v8si a, v8si b, v8si c, v8si d) { vector(8) int vect_iftmp.19; vector(8) int vect_iftmp.18; vector(8) <signed-boolean:32> mask__31.15; vector(8) int vect_iftmp.14; vector(8) <signed-boolean:32> mask__28.11; <bb 2> [local count: 119292720]: mask__28.11_40 = b_50(D) < a_53(D); vect_iftmp.14_43 = .MASK_LOAD (&c, 32B, mask__28.11_40); ---> redundant mask__31.15_44 = b_50(D) >= a_53(D); vect_iftmp.18_47 = .MASK_LOAD (&d, 32B, mask__31.15_44); ---> redundant vect_iftmp.19_49 = .VCOND (b_50(D), a_53(D), vect_iftmp.18_47, vect_iftmp.14_43, 110); return vect_iftmp.19_49; --- could be optimized to --- vect_iftmp.19_49 = .VCOND (b_50(D), a_53(D), d, c); ---