[PATCH] D105935: WIP: [AArch64][GlobalISel] Legalize bswap <2 x i16>

Jon Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 13:15:13 PDT 2021


jroelofs added a comment.

marked as "WIP" because there are a few extraneous copies:

  $ cat bswap.ll
  ; RUN: llc -mtriple=arm64-apple-ios < %s | FileCheck %s
  
  define void @test1(<2 x i16>* %p) {
    %in = load <2 x i16>, <2 x i16>* %p
    %out = call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %in)
    store <2 x i16> %out, <2 x i16>* %p
    ret void
  }
  
  declare <2 x i16> @llvm.bswap.v2i16(<2 x i16>) nounwind readnone

GISel:

  $ ./bin/llc -global-isel=1 -global-isel-abort=1 bswap.ll -mtriple=arm64-apple-ios -o -
  	.section	__TEXT,__text,regular,pure_instructions
  	.globl	_test1                          ; -- Begin function test1
  	.p2align	2
  _test1:                                 ; @test1
  	.cfi_startproc
  ; %bb.0:
  	ldr	h0, [x0]
  	ldr	h1, [x0, #2]
  	mov.h	v0[1], v1[0]
  	fmov	w8, s0
  	mov.s	v0[0], w8
  	rev32.8b	v0, v0
  	ushr.2s	v0, v0, #16
  	fmov	s0, s0
  	mov	h1, v0[1]
  	str	h0, [x0]
  	str	h1, [x0, #2]
  	ret
  	.cfi_endproc
                                          ; -- End function
  .subsections_via_symbols

SDAG:

  $ ./bin/llc -global-isel=0 -global-isel-abort=1 bswap.ll -mtriple=arm64-apple-ios -o -
  	.section	__TEXT,__text,regular,pure_instructions
  	.globl	_test1                          ; -- Begin function test1
  	.p2align	2
  _test1:                                 ; @test1
  	.cfi_startproc
  ; %bb.0:
  	ld1.h	{ v0 }[0], [x0]
  	add	x8, x0, #2                      ; =2
  	ld1.h	{ v0 }[2], [x8]
  	rev32.8b	v0, v0
  	ushr.2s	v0, v0, #16
  	mov.s	w8, v0[1]
  	fmov	w9, s0
  	strh	w9, [x0]
  	strh	w8, [x0, #2]
  	ret
  	.cfi_endproc
                                          ; -- End function
  .subsections_via_symbols


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105935/new/

https://reviews.llvm.org/D105935



More information about the llvm-commits mailing list