[PATCH] D61236: [NFC] Add a static function to do the endian check

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 04:15:10 PDT 2019


steven.zhang marked 2 inline comments as done.
steven.zhang added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:6128
+static bool matchEndian(const SmallVector<int64_t, 4> &ByteOffsets,
+                          int64_t FirstOffset, bool &IsBigEndian) {
+  std::function<unsigned(unsigned, unsigned)> LittleEndianByteAt = [](
----------------
RKSimon wrote:
> Please clang-format the function
oops. copy paste issue when resolve the conflict. 


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:6132
+  std::function<unsigned(unsigned, unsigned)> BigEndianByteAt = [](
+    unsigned BW, unsigned i) { return BW - i - 1; };
+
----------------
RKSimon wrote:
> Anyway that we can avoid duplicate copies of LittleEndianByteAt + BigEndianByteAt?
Maybe, remove the  LittleEndianByteAt + BigEndianByteAt for load combine ? As it is a really simple helper function, and it is only used in one place now
```
auto MemoryByteOffset = [&] (ByteProvider P) {
    assert(P.isMemory() && "Must be a memory byte provider");
    unsigned LoadBitWidth = P.Load->getMemoryVT().getSizeInBits();
    assert(LoadBitWidth % 8 == 0 &&
           "can only analyze providers for individual bytes not bit");
    unsigned LoadByteWidth = LoadBitWidth / 8;
    return IsBigEndianTarget ? LoadByteWidth - P.ByteOffset - 1 : P.ByteOffset;
  };
```


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

https://reviews.llvm.org/D61236





More information about the llvm-commits mailing list