Simplify X * C1 == C2 with wrapping overflow

Marc Glisse marc.glisse@inria.fr
Sun Aug 9 21:24:54 GMT 2020


Odd numbers are invertible in Z / 2^n Z, so X * C1 == C2 can be rewritten 
as X == C2 * inv(C1) when overflow wraps.

mod_inv should probably be updated to better match the other wide_int 
functions, but that's a separate issue.

Bootstrap+regtest on x86_64-pc-linux-gnu.

2020-08-10  Marc Glisse  <marc.glisse@inria.fr>

 	PR tree-optimization/95433
 	* match.pd (X * C1 == C2): Handle wrapping overflow.
 	* expr.c (maybe_optimize_mod_cmp): Qualify call to mod_inv.
 	(mod_inv): Move...
 	* wide-int.cc (mod_inv): ... here.
 	* wide-int.h (mod_inv): Declare it.

 	* gcc.dg/tree-ssa/pr95433-2.c: New file.

-- 
Marc Glisse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: equal2.patch
Type: text/x-diff
Size: 5965 bytes
Desc: 
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200809/906437fa/attachment.bin>


More information about the Gcc-patches mailing list