[PATCH] D103153: [InstCombine] Add fold for extracting known elements from a stepvector

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 05:33:51 PDT 2021


foad added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:361
+        // vector to truncate the index safely.
+        if (IndexC->getValue().getActiveBits() <= (BitWidth - 1)) {
+          auto *Idx =
----------------
All these quantities are unsigned so there is no need to subtract 1 for the sign bit.


================
Comment at: llvm/test/Transforms/InstCombine/vscale_extractelement.ll:259
+; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <vscale x 512 x i8> [[TMP0]], i64 128
+; CHECK-NEXT:    ret i8 [[TMP1]]
+;
----------------
This example *should*  be optimised to `ret i8 128`. stepvector generates unsigned value, so i8 128 is fine (it does not mean -128).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103153



More information about the llvm-commits mailing list