https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120837
--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, bootstrapped/regtested just the obvious removal patch: --- gcc/c-family/c-common.cc.jj 2025-06-30 22:30:59.509417558 +0200 +++ gcc/c-family/c-common.cc 2025-06-30 22:32:01.838628609 +0200 @@ -3422,38 +3422,6 @@ pointer_int_sum (location_t loc, enum tr they are really pointers. */ fold_defer_overflow_warnings (); - /* If what we are about to multiply by the size of the elements - contains a constant term, apply distributive law - and multiply that constant term separately. - This helps produce common subexpressions. */ - if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR) - && !TREE_CONSTANT (intop) - && TREE_CONSTANT (TREE_OPERAND (intop, 1)) - && TREE_CONSTANT (size_exp) - /* If the constant comes from pointer subtraction, - skip this optimization--it would cause an error. */ - && TREE_CODE (TREE_TYPE (TREE_OPERAND (intop, 0))) == INTEGER_TYPE - /* If the constant is unsigned, and smaller than the pointer size, - then we must skip this optimization. This is because it could cause - an overflow error if the constant is negative but INTOP is not. */ - && (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (intop)) - || (TYPE_PRECISION (TREE_TYPE (intop)) - == TYPE_PRECISION (TREE_TYPE (ptrop))))) - { - enum tree_code subcode = resultcode; - tree int_type = TREE_TYPE (intop); - if (TREE_CODE (intop) == MINUS_EXPR) - subcode = (subcode == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR); - /* Convert both subexpression types to the type of intop, - because weird cases involving pointer arithmetic - can result in a sum or difference with different type args. */ - ptrop = build_binary_op (EXPR_LOCATION (TREE_OPERAND (intop, 1)), - subcode, ptrop, - convert (int_type, TREE_OPERAND (intop, 1)), - true); - intop = convert (int_type, TREE_OPERAND (intop, 0)); - } - /* Convert the integer argument to a type the same size as sizetype so the multiply won't overflow spuriously. */ if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype) That regressed FAIL: c-c++-common/restrict-2.c -Wc++-compat scan-tree-dump-times lim2 "Moving statement" 11 FAIL: gcc.dg/tree-ssa/copy-headers-5.c scan-tree-dump ch2 "is now do-while loop" FAIL: gcc.dg/tree-ssa/copy-headers-5.c scan-tree-dump-times ch2 " if " 3 FAIL: gcc.dg/vect/pr57558-2.c scan-tree-dump vect "vectorized 1 loops" FAIL: gcc.dg/vect/pr57558-2.c -flto -ffat-lto-objects scan-tree-dump vect "vectorized 1 loops" FAIL: c-c++-common/restrict-2.c -std=gnu++98 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++11 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++14 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++17 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++20 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++23 scan-tree-dump-times lim2 "Moving statement" 11 FAIL: c-c++-common/restrict-2.c -std=gnu++26 scan-tree-dump-times lim2 "Moving statement" 11 on both x86_64-linux and i686-linux.