[all-commits] [llvm/llvm-project] 302f7a: [VectorCombine] Fold concat(binop(a, c), binop(b, d)...

Aayush Shrivastava via All-commits all-commits at lists.llvm.org
Wed Jul 8 02:35:15 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 302f7aa18e0d68d9db74c2586bd66ef8e4d98e53
      https://github.com/llvm/llvm-project/commit/302f7aa18e0d68d9db74c2586bd66ef8e4d98e53
  Author: Aayush Shrivastava <iamaayushrivastava at gmail.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

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

  Log Message:
  -----------
  [VectorCombine] Fold concat(binop(a,c), binop(b,d)) -> binop(concat(a,b), concat(c,d)) for i1 vectors (#206087)

Fixes #205707 

`VectorCombine::foldShuffleOfBinops` rewrites `shuffle(binop(a,c),
binop(b,d))` into `binop(shuffle(a,b), shuffle(c,d))` but only when the
new form is strictly cheaper. For concat shuffles of i1 vectors, both
forms have equal cost, so the transform was silently rejected.

This fix allows the equal-cost transform when both binops are single-use
`BinaryOperators` (not icmps, to avoid widening narrow AVX-512
comparisons), canonicalising the IR to a wider binop.

The motivating case is AVX-512 mask operations: `NOT(concat(XOR(a,c),
XOR(b,d)))` becomes `NOT(XOR(concat(a,b), concat(c,d)))`, which the
backend naturally selects as `kxnorq`, reducing `kxord + kxord +
kunpckdq + knotq` (4 instructions) to `kunpckdq + kunpckdq + kxnorq` (3
instructions).



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