Kishan Parmar 647bd0a027 rs6000: Avoid undefined behavior caused by overflow and invalid shifts
While building GCC with --with-build-config=bootstrap-ubsan on
powerpc64le-unknown-linux-gnu, multiple UBSAN runtime errors were
encountered in rs6000.cc and rs6000.md due to undefined behavior
involving left shifts on negative values and shift exponents equal to
or exceeding the type width.

The issue was in bit pattern recognition code
(in can_be_rotated_to_negative_lis and can_be_built_by_li_and_rldic),
where signed values were shifted without handling negative inputs or
guarding against shift counts equal to the type width, causing UB.
The fix ensures shifts and rotations are done unsigned HOST_WIDE_INT,
and casting back only where needed (like for arithmetic right shifts)
with proper guards to prevent shift-by-64.

2025-07-31  Kishan Parmar  <kishan@linux.ibm.com>

gcc:
	PR target/118890
	* config/rs6000/rs6000.cc (can_be_rotated_to_negative_lis): Avoid left
	shift of negative value and guard shift count.
	(can_be_built_by_li_and_rldic): Likewise.
	(rs6000_emit_set_long_const): Likewise.
	* config/rs6000/rs6000.md (splitter for plus into two 16-bit parts): Fix
	UB from overflow in addition.
2025-07-31 17:05:02 +05:30
2025-07-29 00:19:24 +00:00
2025-07-26 00:19:51 +00:00
2025-07-31 00:21:08 +00:00
2025-07-18 00:19:21 +00:00
2025-07-31 00:21:08 +00:00
2025-07-24 00:20:56 +00:00
2025-07-22 00:19:29 +00:00
2025-07-31 00:21:08 +00:00
2025-07-23 00:20:17 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.8%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.3%