[PATCH] D76983: [InstCombine] Transform extractelement-trunc -> bitcast-extractelement

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 07:00:39 PDT 2020


spatel added a comment.

I think we're pretty close now.
Added another test, so please rebase/update:
rGbc60cdcc3f8 <https://reviews.llvm.org/rGbc60cdcc3f86606f312bc3f43f14fe0c5de225a5>



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:869-872
+          DL.isBigEndian()
+              ? (VecOpIdx + 1) * TruncRatio - 1
+              : VecOpIdx * TruncRatio;
+
----------------
The index math can overflow:
  define i8 @src(<1073741824 x i32> %x) {
    %e = extractelement <1073741824 x i32> %x, i32 1073741823
    %t = trunc i32 %e to i8
    ret i8 %t
  }

To be safe(r), use uint64_t for these variables. Normally, we want to have a regression test for a known problem like that, but I'm going to suggest **not** adding that because it could cost a lot of execution time for a test case that is probably not going to occur in the real-world before LLVM is long gone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76983





More information about the llvm-commits mailing list