[PATCH] Improved handling of division/modulus in bit CCP.

Roger Sayle roger@nextmovesoftware.com
Sun Aug 22 14:50:23 GMT 2021


This patch implements support for TRUNC_MOD_EXPR and TRUNC_DIV_EXPR
in tree-ssa's bit CCP pass.  This is mostly for completeness, as the
VRP pass already provides better bounds for these operations, but
seeing mask values of all_ones in my debugging/instrumentation logs
seemed overly pessimistic.  With this patch, the expression X%10
has a nonzero bits of 0x0f (for unsigned X), likewise (X&1)/3 has
a known value of zero, and (X&3)/3 has a nonzero bits mask of 0x1.

This patch has been tested on x86_64-pc-linux-gnu with "make bootstrap"
and "make -k check" with no new failures.  Ok for mainline?


2021-08-22  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
 	* tree-ssa-ccp.c (bit_value_binop) [TRUNC_MOD_EXPR, TRUNC_DIV_EXPR]:
 	Provide bounds for unsigned (and signed with non-negative operands)
 	division and modulus.

Roger
--

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patchl2.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210822/a62cd8f3/attachment.txt>


More information about the Gcc-patches mailing list