This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][PR target/80358][7 regression] Fix boundary check error in expand_block_compare
- From: Aaron Sawdey <acsawdey at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Segher Boessenkool <segher at kernel dot crashing dot org>, David Edelsohn <dje dot gcc at gmail dot com>, Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>
- Date: Fri, 07 Apr 2017 14:38:50 -0500
- Subject: [PATCH][PR target/80358][7 regression] Fix boundary check error in expand_block_compare
- Authentication-results: sourceware.org; auth=none
Turns out we get passed const -1 for the length arg from this code.
ROUND_UP adds load_mode_size to that resulting in a small positive
number, hilarity ensues. Fixed by computing a sensible limit and using
IN_RANGE instead, which won't overflow in this way.
OK for trunk if bootstrap/regtest in progress passes?
2017-04-07 Aaron Sawdey <acsawdey@linux.vnet.ibm.com>
PR target/80358
* config/rs6000/rs6000.c (expand_block_compare): Fix boundary check.
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 246771)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -19672,8 +19672,9 @@
unsigned int load_mode_size = GET_MODE_SIZE (load_mode);
/* We don't want to generate too much code. */
- if (ROUND_UP (bytes, load_mode_size) / load_mode_size
- > (unsigned HOST_WIDE_INT) rs6000_block_compare_inline_limit)
+ unsigned HOST_WIDE_INT max_bytes =
+ load_mode_size * (unsigned HOST_WIDE_INT) rs6000_block_compare_inline_limit;
+ if (!IN_RANGE (bytes, 1, max_bytes))
return false;
bool generate_6432_conversion = false;
--
Aaron Sawdey, Ph.D. acsawdey@linux.vnet.ibm.com
050-2/C113 (507) 253-7520 home: 507/263-0782
IBM Linux Technology Center - PPC Toolchain