[PATCH] Added instruction combine to transform few more negative values addition to subtraction (Part 3)

Dinesh Dwivedi dinesh.d at samsung.com
Thu Jun 26 00:12:35 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:962
@@ -961,2 +961,3 @@
 //   ADD(XOR(OR(Z, NOT(C)), C)), 1) == NEG(AND(Z, C))
 //   TODO: ADD(XOR(AND(Z, ~C), ~C), 1) == NEG(OR(Z, C)) if C is even
+//   XOR(AND(Z, ~C), (~C + 1)) == NEG(OR(Z, C)) if C is odd
----------------
Jingyue Wu wrote:
> Make sure this TODO goes away after you rebase. 
sure, will take care of it.

================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:998
@@ -997,1 +997,3 @@
 
+  // Restore LSH and RHS
+  LHS = I.getOperand(0);
----------------
Jingyue Wu wrote:
> typo "LHS"
updated.

================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1007
@@ +1006,3 @@
+  // C2 is ODD
+  // LHS = XOR(Y, C1), Y = AND(Z, C2), C1 == (C2 + 1) => LHS == NOT(AND(Z, ~C2))
+  // ADD(LHS, RHS) == SUB(RHS, AND(Z, ~C2))
----------------
Jingyue Wu wrote:
> ```
> LHS == NOT(AND(Z, ~C2))
> ```
> is not consistent with previous comments using
> ```
> NEG(OR(Z, C))
> ```
> 
> Are they mathematically equivalent? If so, could you make the comments consistent? 
updated.

================
Comment at: test/Transforms/InstCombine/add2.ll:154
@@ +153,3 @@
+define i32 @test17(i32 %x) {
+ %x.not = and i32 %x, -1431655766
+ %add3 = xor i32 %x.not, -1431655765
----------------
Jingyue Wu wrote:
> I'd love to see some comments on what math expression these IR instructions compute, and what those magic numbers (e.g., -1431655766) mean. 
> 
> Same for the next two test cases. 
updated

http://reviews.llvm.org/D4210






More information about the llvm-commits mailing list