[PATCH] Added instruction combine to transform few more negative values addition to subtraction
Dinesh Dwivedi
dinesh.d at samsung.com
Thu Jun 19 03:03:40 PDT 2014
================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:928
@@ +927,3 @@
+
+ // This function creates 2 instructions to replace ADD, we need atleast one of
+ // LHS or RHS to have one use to ensure benefit in transform.
----------------
Nick Lewycky wrote:
> "atleast" --> "at least"
updated
================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:951
@@ +950,3 @@
+ if (match(X, m_Xor(m_Value(Y), m_APInt(C1)))) {
+ if (match(Y, m_Or(m_Value(Z), m_APInt(C2))) && (*C2 == ~(*C1))) {
+ Value *NewAnd = Builder->CreateAnd(Z, *C1);
----------------
Nick Lewycky wrote:
> Optional: *C2 == ~(*C1) might be more efficient as !C2->intersects(*C1). It isn't, but in theory we could improve intersects to not compute an intermediate value (ie., it doesn't need to look at all the bits once it finds a pair are set in both).
problem with intersects() is that it just ensure that same bit is not set in both C1 and C2 but does not ensure that if one but is set in one, it will not set in second.
We can compute xor and then check if result is all zero but I am not sure if that is more efficient than current code,
it will sure reduce readability though.
================
Comment at: test/Transforms/InstCombine/add2.ll:142
@@ +141,1 @@
+}
\ No newline at end of file
----------------
Nick Lewycky wrote:
> Please make sure there's a newline at the end of the file.
>
updated.
http://reviews.llvm.org/D3733
More information about the llvm-commits
mailing list