Static cast size_t -> int64_t instead of vice versa for equals comparisons
authorGeoffrey Martin-Noble <gcmn@google.com>
Fri, 31 May 2019 23:41:21 +0000 (16:41 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:13:49 +0000 (20:13 -0700)
commitc912981bbd6d94218d66546aa22620660894f0ae
treeb0dfaa826a3b3f1cf7449e835bc1d06134b050fd
parente7b337acf85843e026f0ac77e7bad0920610ef7d
Static cast size_t -> int64_t instead of vice versa for equals comparisons

    These were just introduced by a previous CL moving MemRef getRank to return int64_t. size_t could be smaller than 64 bits and in equals comparisons, signed vs unsigned doesn't matter. In these cases, we know right now that the particular int64_t is not larger than max size_t (because it currently comes directly from a size() call), the alternative cast plus equals comparison is always safe, so we might as well do it that way and no longer require reasoning deeper into the callstack.

    We are already assuming that size() calls fit into int64_t in a number of other cases like the aforementioned getRank() (since exabytes of RAM are rare). If we want to avoid this assumption we will have to come up with a principled way to do it throughout.

--

PiperOrigin-RevId: 250980297
mlir/examples/Linalg/Linalg1/lib/ViewOp.cpp
mlir/lib/StandardOps/Ops.cpp
mlir/lib/VectorOps/VectorOps.cpp