[all-commits] [llvm/llvm-project] 08f904: [VectorCombine] Fold "(or (zext (bitcast X)), (shl...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Wed Dec 11 08:41:18 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 08f904011f4b17e46b7616737a5dec01e3563c80
      https://github.com/llvm/llvm-project/commit/08f904011f4b17e46b7616737a5dec01e3563c80
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2024-12-11 (Wed, 11 Dec 2024)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    M llvm/test/Transforms/PhaseOrdering/X86/concat-boolmasks.ll

  Log Message:
  -----------
  [VectorCombine] Fold "(or (zext (bitcast X)), (shl (zext (bitcast Y)), C))" -> "(bitcast (concat X, Y))" MOVMSK bool mask style patterns (#119559)

Mask/Bool vectors are often bitcast to/from scalar integers, in particular when concatenating mask results, often this is due to the difficulties of working with vector of bools on C/C++. On x86 this typically involves the MOVMSK/KMOV instructions.

To concatenate bool masks, these are typically cast to scalars, which are then zero-extended, shifted and OR'd together.

This patch attempts to match these scalar concatenation patterns and convert them to vector shuffles instead. This in turn often assists with further vector combines, depending on the cost model.

Fixes #111431



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list