diff --git a/gcc/match.pd b/gcc/match.pd index 7f16fd4e081..1d6428bf7e5 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3136,7 +3136,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) #if GENERIC (simplify (pointer_plus (convert:s (pointer_plus:s @0 @1)) @3) - (convert:type (pointer_plus @0 (plus @1 @3)))) + (pointer_plus (convert:type @0) (plus @1 @3))) #endif /* Pattern match diff --git a/gcc/testsuite/gcc.c-torture/execute/pr124358.c b/gcc/testsuite/gcc.c-torture/execute/pr124358.c new file mode 100644 index 00000000000..81bf6a29d7c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr124358.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/124358 */ + +[[gnu::noipa]] void +foo (int d) +{ + static int u = 11; + if (d != u++) + __builtin_abort (); +} + +int +main () +{ + int a[1][4] = { 11, 12, 13, 14 }; + int (*p)[4] = a; + for (int i = 0; i < 1; i++) + for (int j = 0; j < 4; j++) + foo (*(*(p + i) + j)); +}