First Part: http://reviews.llvm.org/D3733
This patch enable following transform
(x + (~(y | c) + 1) --> x - (y | c) if c is even (x + (~((y >> z) | c) + 1) --> x - ((y>>z) | c) if c is even
Z3 verification code:
http://rise4fun.com/Z3/ZA06
|  Differential  D4209  
Added instruction combine to transform few more negative values addition to subtraction  (Part 2) Authored by dinesh.d on Jun 19 2014, 5:02 AM. 
Details First Part: http://reviews.llvm.org/D3733 This patch enable following transform (x + (~(y | c) + 1) --> x - (y | c) if c is even (x + (~((y >> z) | c) + 1) --> x - ((y>>z) | c) if c is even Z3 verification code: http://rise4fun.com/Z3/ZA06 
Diff Detail 
 Event TimelineComment Actions Hi Dinesh, I didn't see the code handling the second case in your summary: (x + (~((y >> z) | c) + 1) --> x - ((y>>z) | c) if c is even Am I missing anything? Thanks, Comment Actions Hi Jingyue, Added code can handle both cases. Basically it checks operands of OR and can deal with When I coded for this, I was looking at PR14365 and it has both pattern for XOR(AND()) and I Sorry for confusing comment. Comment Actions I see. I wasn't involved with the first part, so was confused. Thanks for clarification! 
 Comment Actions Thanks. I have replied inline. I will update code based on your comment on them. 
 Comment Actions forgot to reply for else if part. 
 
 Comment Actions Sorry for delay in reply. I have added comments inline. 
 
 Comment Actions Removed code setting NSW/ NUW flags 
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||