https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111913
Bug ID: 111913
Summary: GCC: 14: -O1 compile __builtin_popcount fails while
-O0 succeeds
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 141242068 at smail dot nju.edu.cn
Target Milestone: ---
When compile this program with `-O1`, gcc crashes:
```
int f(unsigned int x, unsigned int y)
{
return __builtin_popcount (x&y) + __builtin_popcount (y|x--);
}
```
If change the optimization level to `-O0`, then nothing happens.
Compiler Explorer: https://gcc.godbolt.org/z/naoebKMor
The stack dump:
```
<source>: In function 'f':
<source>:4:1: error: invalid conversion in gimple call
4 | }
| ^
unsigned int
int
_3 = __builtin_popcount (x_6(D));
<source>:4:1: error: invalid conversion in gimple call
unsigned int
int
_11 = __builtin_popcount (y_7(D));
<source>:4:1: error: type mismatch in binary expression
int
unsigned int
unsigned int
_9 = _3 + _11;
during GIMPLE pass: forwprop
<source>:4:1: internal compiler error: verify_gimple failed
0x231f49e internal_error(char const*, ...)
???:0
0x1164659 verify_gimple_in_cfg(function*, bool, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```