[PATCH] D73892: [SelectionDAG] Optimize build_vector of truncates and shifts

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 05:23:05 PST 2020


nhaehnle added reviewers: spatel, lebedev.ri.
nhaehnle accepted this revision.
nhaehnle added a comment.
This revision is now accepted and ready to land.

LGTM, but wait a few days to give others a chance to weigh in.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:17486-17488
+  // Only for little endian
+  if (!DAG.getDataLayout().isLittleEndian())
+    return SDValue();
----------------
sebastian-ne wrote:
> arsenm wrote:
> > Why does this matter? This doesn't touch memory
> I think it does matter for the shifts and for bitcasting a vector to a number.
> If I’m not mistaken, for big endian the function should convert like this:
> 
> 
> ```
> Simplify (build_vec (trunc (srl $1 (2 * half-width)))
>                     (trunc (srl $1 half-width))
>                     (trunc $1) …)
> to (bitcast $1)
> ```
> 
> That could be fixed easily, however the selection-dag bitcast documentation states that there may be more shuffling on big endian architectures?
> https://llvm.org/doxygen/ISDOpcodes_8h_source.html#l00590
Right, because bitcasts are defined as behaving as-if you store to and then load from memory. Which may well be quite problematic, but that's what the documentation says...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73892





More information about the llvm-commits mailing list