[PATCH] D68811: [CVP] Remove a masking operation if range information implies it's a noop

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 09:54:51 PDT 2019


lebedev.ri added a comment.

I agree that instcombine likes that pattern, so it may make sense to deal with it.



================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:65
 STATISTIC(NumSRems,     "Number of srem converted to urem");
 STATISTIC(NumSExt,      "Number of sext converted to zext");
 STATISTIC(NumOverflows, "Number of overflow checks removed");
----------------
`STATISTIC(NumAndMasks,      "Number of constant low-bit-masking ands dropped");`


================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:715-716
+
+  ConstantRange LRange = LVI->getConstantRange(LHS, BB, BinOp);
+  if (!LRange.getUnsignedMax().ule(RHS->getValue()))
+    return false;
----------------
Do we want to query constanrange, or use `getPredicateAt()`?
Different folds here take different routes.
Should this be:
```
  if (LVI->getPredicateAt(ICmpInst::ICMP_ULE, LHS, RHS, SDI) !=
      LazyValueInfo::True)
    return false;
```
?  (i don't know)


================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:720-721
+  BinOp->replaceAllUsesWith(LHS);
+  BinOp->eraseFromParent();
+  return true;
+}
----------------
`++NumAndMasks();`


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68811/new/

https://reviews.llvm.org/D68811





More information about the llvm-commits mailing list