https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121266
Bug ID: 121266 Summary: [16 regression] (x86) Missed an '-Os' optimization on setting a register value to -1 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: Explorer09 at gmail dot com Target Milestone: --- I found this when testing the trunk version of GCC in Compiler Explorer (https://godbolt.org/z/z9oMWKP5P) There was a little optimization in gcc (15.1.0 and before) enabled in '-Os' mode that would use 'or' instruction instead of 'mov' when setting a local variable's value to -1. The trunk version (16.0.0 20250726) currently misses it. ```c #include <stdint.h> int32_t func_32(void) { return -1; } int64_t func_64(void) { return -1; } ``` x86-64 gcc 15.1 (with '-Os' option): ```assembly func_32: orl $-1, %eax ret func_64: orq $-1, %rax ret ``` x86-64 gcc trunk (with '-Os' option): ```assembly func_32: movl $-1, %eax ret func_64: movq $-1, %rax ret ``` Note, the --version option of gcc in Compiler Explorer outputs this: ``` gcc (Compiler-Explorer-Build-gcc-11518c841dda4d417573e41ded69bd1469ad6d1f-binutils-2.44) 16.0.0 20250726 (experimental) Copyright (C) 2025 Free Software Foundation, Inc. ```