[all-commits] [llvm/llvm-project] 4acb96: [SelectionDAG] Tidy up around endianness and isCon...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Oct 16 05:54:06 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4acb96c99f3b9c414f403f6e1ab2b317851abf0f
      https://github.com/llvm/llvm-project/commit/4acb96c99f3b9c414f403f6e1ab2b317851abf0f
  Author: Björn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2023-10-16 (Mon, 16 Oct 2023)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

  Log Message:
  -----------
  [SelectionDAG] Tidy up around endianness and isConstantSplat (#68212)

The BuildVectorSDNode::isConstantSplat function could depend on
endianness, and it takes a bool argument that can be used to indicate
if big or little endian should be considered when internally casting
from a vector to a scalar. However, that argument is default set to
false (= little endian). And in many situations, even in target
generic code such as DAGCombiner, the endianness isn't specified when
using the function.

The intent with this patch is to highlight that endianness doesn't
matter, depending on the context in which the function is used.

In DAGCombiner the code is slightly refactored. Back in the days when
the code was written it wasn't possible to request a MinSplatBits
size when calling isConstantSplat. Instead the code re-expanded the
found SplatValue to match with the EltBitWidth. Now we can just
provide EltBitWidth as MinSplatBits and remove the logic for doing
the re-expand.

While being at it, tidying up around isConstantSplat, this patch also
adds an explicit check in BuildVectorSDNode::isConstantSplat to break
out from the loop if trying to split an on VecWidth into two halves.
Haven't been able to prove that there could be miscompiles involved
if not doing so. There are lit tests that trigger that scenario,
although I think they happen to later discard the returned SplatValue
for other reasons.




More information about the All-commits mailing list