[AArch64] recognise zip1/zip2 with flipped operands (#167235) Currently, the following two snippets get treated very differently from each other (https://godbolt.org/z/rYGj9TGz6): ```LLVM define <8 x i8> @foo(<8 x i8> %x, <8 x i8> %y) local_unnamed_addr #0 { entry: %0 = shufflevector <8 x i8> %x, <8 x i8> %y, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11> ret <8 x i8> %0 } define <8 x i8> @bar(<8 x i8> %x, <8 x i8> %y) local_unnamed_addr #0 { entry: %0 = shufflevector <8 x i8> %x, <8 x i8> %y, <8 x i32> <i32 8, i32 0, i32 9, i32 1, i32 10, i32 2, i32 11, i32 3> ret <8 x i8> %0 } ``` ``` foo: // @foo zip1 v0.8b, v0.8b, v1.8b ret .LCPI1_0: .byte 8 // 0x8 .byte 0 // 0x0 .byte 9 // 0x9 .byte 1 // 0x1 .byte 10 // 0xa .byte 2 // 0x2 .byte 11 // 0xb .byte 3 // 0x3 bar: // @bar adrp x8, .LCPI1_0 mov v0.d[1], v1.d[0] ldr d1, [x8, :lo12:.LCPI1_0] tbl v0.8b, { v0.16b }, v1.8b ret ``` The reason is that `isZIPMask` does not recognise the pattern when the operands are flipped. This PR fixes `isZIPMask` so that both `foo` and `bar` get compiled as expected: ``` foo: // @foo zip1 v0.8b, v0.8b, v1.8b ret bar: // @bar zip1 v0.8b, v1.8b, v0.8b ret ``` I intend to open a similar follow-up PR for `isTRNMask`, which seems to have the same problem. I noticed this while working on https://github.com/llvm/llvm-project/issues/137447, though the change does not on itself fix that issue.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.