[PATCH] D76611: [SCCP] Use ranges for predicate info conditions.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 11:16:56 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:1299
+      LatticeVal &IV = ValueState[I];
+      if (CopyOf->getType()->isIntegerTy()) {
+        auto NewCR =
----------------
fhahn wrote:
> efriedma wrote:
> > Do we want to try to handle the case where we have a constant expression of integer type?
> Ah yes, I've change it to use ranges only if either operand is a constant range.
> 
> I've added a test with a compare of 2 constant ranges. Currently this just swaps the known values and is not too helpful in that case (f14_constexpr2). 
> 
> Also, would it be legal to fold something like `i1 icmp eq (i32 ptrtoint (i32* @B to i32), i32 ptrtoint (i32* @B to i32)` to `true`? If it is, it looks like ConstantExpr currently misses that fold.
I think the order of the conditions might be backwards? Consider if OriginalVal is a ConstantRange, and CondVal is a Constant.

-----

I briefly tried the following, and it seems to fold (just passing it to "opt -S"):

@B = global i32 0
@C = global i1 icmp eq (i32 ptrtoint (i32* @B to i32), i32 ptrtoint (i32* @B to i32))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76611





More information about the llvm-commits mailing list