[PATCH] Added InstCombine transform for pattern " ((X % Z) + (Y % Z)) % Z -> (X + Y) % Z ".

Ankur Garg ankur29.garg at samsung.com
Wed Sep 17 04:36:44 PDT 2014


Hi nlopes,
I have modified it to check for the cases in which the addition overflows. The check is only valid when the operands or some their bits are known prior to the calculation, though. The transformation won't work for the cases in which the operands are completely unknown. I have included the test cases with both cases - one in which the addition overflows and another one in which it doesn't.
I think it can't be extended to the cases where the operands are completely variables because it is not possible to figure out whether their addition will overflow or not.
Please suggest if there is any other way to handle the cases for variable operands.

Thanks.
Regards,
Ankur Garg

http://reviews.llvm.org/D5351

Files:
  lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
  test/Transforms/InstCombine/rem.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5351.13776.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140917/30916b04/attachment.bin>


More information about the llvm-commits mailing list