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

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 08:19:54 PST 2020


sebastian-ne added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:17486-17488
+  // Only for little endian
+  if (!DAG.getDataLayout().isLittleEndian())
+    return SDValue();
----------------
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


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