[llvm] [X86] Fold splat AND on VGF2P8AFFINEQB source (PR #193364)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 19:14:22 PDT 2026


================
@@ -0,0 +1,182 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+gfni,+avx2 | FileCheck %s
+
+declare <16 x i8> @llvm.x86.vgf2p8affineqb.128(<16 x i8>, <16 x i8>, i8)
+
+define <16 x i8> @test_const_splat_on_const_matrix(<16 x i8> %src) nounwind {
+; CHECK-LABEL: test_const_splat_on_const_matrix:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vgf2p8affineqb $0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; CHECK-NEXT:    retq
+  %and = and <16 x i8> %src, splat(i8 15)
+  %gfni = call <16 x i8> @llvm.x86.vgf2p8affineqb.128(<16 x i8> %and, <16 x i8> <i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128, i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128>, i8 0)
+  ret <16 x i8> %gfni
+}
+
+define <32 x i8> @test_const_splat_on_const_matrix256(<32 x i8> %src) nounwind {
+; CHECK-LABEL: test_const_splat_on_const_matrix256:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vgf2p8affineqb $0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
+; CHECK-NEXT:    retq
+  %and = and <32 x i8> %src, splat(i8 15)
+  %gfni = call <32 x i8> @llvm.x86.vgf2p8affineqb.256(<32 x i8> %and, <32 x i8> <i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128, i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128, i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128, i8 64, i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 -128>, i8 0)
+  ret <32 x i8> %gfni
+}
+
+define <16 x i8> @test_const_splat_parity_matrix(<16 x i8> %src) nounwind {
----------------
WalterKruger wrote:

I wanted to test the same situation as `test_const_splat_on_const_matrix` but with a different matrix. Do you want me to remove it or add a comment?

https://github.com/llvm/llvm-project/pull/193364


More information about the llvm-commits mailing list