https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93081
Bug ID: 93081 Summary: insertation followed by another inseration to the same location is not optimized away Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Testcase: /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-optimized" } */ #define vector __attribute__((__vector_size__(16) )) vector int f(vector int a, int b, int c) { a[0] = b; a[0] = c; return a; } /* { dg-final { scan-tree-dump-times "BIT_INSERT_EXPR" 1 "optimized" } } */ --- CUT --- Code added to match.pd which will fix it: /* Inserting into the same location as previously just over writes the location. */ (simplify (bit_insert (bit_insert @0 @1 @2) @3 @2) (bit_insert @0 @3 @2))