[PATCH] D49229: [InstCombine] Fold redundant masking operations of shifted value

Diogo N. Sampaio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 30 04:58:33 PDT 2018


dnsampaio marked an inline comment as done.
dnsampaio added a comment.

As we are replacing all the uses of the DeadAnd, it is not required to create and replace the visiting Or operation. Replace all uses does the job already.



================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2058
+      Builder.CreateBinOp(Opcode, And, ConstantInt::get(I.getType(), *ShftAmt));
+  DeadAnd->replaceAllUsesWith(NewShift);
+  return BinaryOperator::CreateOr(And, NewShift);
----------------
lebedev.ri wrote:
> But how do you know it's dead? I don't think you checked that it is one-use?
> And if it is one-use, then it will be dead after the parent instruction will be replaced, so why do we care?
> I guess you want to add a bit more tests.
The new shift, being created, holds the same value of the DeadAnd. So we can just replace all uses of the DeadAnd with the new shifted value. Test added, to be uploaded.



https://reviews.llvm.org/D49229





More information about the llvm-commits mailing list