On Tue, Jan 31, 2023 at 10:31:03PM -0500, Michael Meissner wrote: > Ok, I tracked down the source of the bug. The CCP pass is depending on the > precision field. Unfortunately in tree-core.h, the precision is a 10 integer > bit field, so 1,024 will become 0. > > Having a 0 precision meant that the hwint function for sign extending a value > would generate: > > (HOST_WIDE_INT)(((unsigned HOST_WIDE_INT)value << 64) >> 64) > > which is undefined behavior in C and C++. On the x86_64 doing the shift left > and then right gives you the initial value (which was -1), while on the > PowerPC > it always gives you 0. The CCP code was assuming if it wasn't -1, that it was > an integer, but the TDO type is opaque, not integer.
Variable 64-bit shifts on x86 mask the shift amount to 6 bits, while on PowerPC it is masked to 7 bits. It sounds like that is what you hit, with some -O0 build perhaps. But either way UB is UB, the program has no meaning, any output is correct, no output is correct as well :-) Nasal demons and all that. bootstrap-ubsan should have found this? Segher