[all-commits] [llvm/llvm-project] 5d1029: [VectorCombine] Handle shuffle of selects (#128032)

hanbeom via All-commits all-commits at lists.llvm.org
Thu Mar 6 04:44:08 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d1029b4a87f36a394c169b89b26a74d17f7ff01
      https://github.com/llvm/llvm-project/commit/5d1029b4a87f36a394c169b89b26a74d17f7ff01
  Author: hanbeom <kese111 at gmail.com>
  Date:   2025-03-06 (Thu, 06 Mar 2025)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    A llvm/test/Transforms/VectorCombine/X86/shuffle-of-selects.ll

  Log Message:
  -----------
  [VectorCombine] Handle shuffle of selects (#128032)

(shuffle(select(c1,t1,f1)), (select(c2,t2,f2)), m)
-> (select (shuffle c1,c2,m), (shuffle t1,t2,m), (shuffle f1,f2,m))

The behaviour of SelectInst on vectors is the same as for
`V'select[i] = Condition[i] ? V'True[i] : V'False[i]`.

If a ShuffleVector is performed on two selects, it will be like:
`V'[mask] = (V'select[i] = Condition[i] ? V'True[i] : V'False[i])`

That's why a ShuffleVector with two SelectInst is equivalent to
first ShuffleVector Condition/True/False and then SelectInst that
result.

This patch implements the transforming described above.

Proof: https://alive2.llvm.org/ce/z/97wfHp
Fixes #120775



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