[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 05:03:58 PDT 2018


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


================
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);
----------------
dnsampaio wrote:
> 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.
> 
Perhaps the naming is misleading. It is "dead" in the sense that the new shift holds the same value, and all it's uses must be replaced. But no, it is not restricted to be a single use. Adding example test.


https://reviews.llvm.org/D49229





More information about the llvm-commits mailing list