CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
2126 lines
61 KiB
LLVM
2126 lines
61 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -mtriple=riscv32 -mattr=+experimental-p,+m,+zbb \
|
|
; RUN: -verify-machineinstrs < %s | \
|
|
; RUN: FileCheck --check-prefixes=CHECK,RV32 %s
|
|
; RUN: llc -mtriple=riscv64 -mattr=+experimental-p,+m,+zbb \
|
|
; RUN: -verify-machineinstrs < %s | \
|
|
; RUN: FileCheck --check-prefixes=CHECK,RV64 %s
|
|
|
|
; Test basic add/sub operations for v2i16
|
|
define <2 x i16> @test_padd_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_padd_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = add <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psub_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_psub_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psub.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = sub <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test basic add/sub operations for v4i8
|
|
define <4 x i8> @test_padd_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_padd_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = add <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psub_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_psub_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psub.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = sub <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test bitwise operations for v2i16 (use scalar instructions)
|
|
define <2 x i16> @test_and_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_and_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: and a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = and <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_or_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_or_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: or a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = or <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_xor_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_xor_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xor a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = xor <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_andn_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_andn_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: andn a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%not = xor <2 x i16> %b, splat (i16 -1)
|
|
%res = and <2 x i16> %a, %not
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_orn_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_orn_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: orn a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%not = xor <2 x i16> %b, splat (i16 -1)
|
|
%res = or <2 x i16> %a, %not
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; FIXME: A bitcast is getting in the way on RV64.
|
|
define <2 x i16> @test_xnor_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_xnor_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xnor a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%not = xor <2 x i16> %b, splat (i16 -1)
|
|
%res = xor <2 x i16> %a, %not
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test bitwise operations for v4i8 (use scalar instructions)
|
|
define <4 x i8> @test_and_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_and_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: and a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = and <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_or_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_or_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: or a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = or <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_xor_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_xor_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xor a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = xor <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_andn_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_andn_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: andn a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%not = xor <4 x i8> %b, splat (i8 -1)
|
|
%res = and <4 x i8> %a, %not
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_orn_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_orn_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: orn a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%not = xor <4 x i8> %b, splat (i8 -1)
|
|
%res = or <4 x i8> %a, %not
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; FIXME: A bitcast is getting in the way on RV64.
|
|
define <4 x i8> @test_xnor_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_xnor_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xnor a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%not = xor <4 x i8> %b, splat (i8 -1)
|
|
%res = xor <4 x i8> %a, %not
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_not_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_not_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%res = xor <2 x i16> %a, splat(i16 -1)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_not_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_not_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%res = xor <4 x i8> %a, splat(i8 -1)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test saturating add operations for v2i16
|
|
define <2 x i16> @test_psadd_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_psadd_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psadd.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psaddu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_psaddu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psaddu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test saturating sub operations for v2i16
|
|
define <2 x i16> @test_pssub_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pssub_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pssub.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.ssub.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_pssubu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pssubu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pssubu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.usub.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test saturating add operations for v4i8
|
|
define <4 x i8> @test_psadd_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_psadd_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psadd.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psaddu_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_psaddu_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psaddu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test saturating sub operations for v4i8
|
|
define <4 x i8> @test_pssub_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pssub_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pssub.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_pssubu_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pssubu_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pssubu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test averaging floor signed operations for v2i16
|
|
define <2 x i16> @test_paadd_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_paadd_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: paadd.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%ext.a = sext <2 x i16> %a to <2 x i32>
|
|
%ext.b = sext <2 x i16> %b to <2 x i32>
|
|
%add = add nsw <2 x i32> %ext.a, %ext.b
|
|
%shift = ashr <2 x i32> %add, <i32 1, i32 1>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test averaging floor unsigned operations for v2i16
|
|
define <2 x i16> @test_paaddu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_paaddu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: paaddu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%and = and <2 x i16> %a, %b
|
|
%xor = xor <2 x i16> %a, %b
|
|
%shift = lshr <2 x i16> %xor, <i16 1, i16 1>
|
|
%res = add <2 x i16> %and, %shift
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test averaging floor signed operations for v4i8
|
|
define <4 x i8> @test_paadd_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_paadd_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: paadd.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%ext.a = sext <4 x i8> %a to <4 x i16>
|
|
%ext.b = sext <4 x i8> %b to <4 x i16>
|
|
%add = add nsw <4 x i16> %ext.a, %ext.b
|
|
%shift = ashr <4 x i16> %add, <i16 1, i16 1, i16 1, i16 1>
|
|
%res = trunc <4 x i16> %shift to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test averaging floor unsigned operations for v4i8
|
|
define <4 x i8> @test_paaddu_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_paaddu_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: paaddu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%and = and <4 x i8> %a, %b
|
|
%xor = xor <4 x i8> %a, %b
|
|
%shift = lshr <4 x i8> %xor, <i8 1, i8 1, i8 1, i8 1>
|
|
%res = add <4 x i8> %and, %shift
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_pabs_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_pabs_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabs.h a0, a0
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.abs.v2i16(<2 x i16> %a, i1 0)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_pabs_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_pabs_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabs.b a0, a0
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %a, i1 0)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test absolute difference signed for v2i16
|
|
define <2 x i16> @test_pdif_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pdif_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabd.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <2 x i16> @llvm.smin.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
%max = call <2 x i16> @llvm.smax.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
%res = sub <2 x i16> %max, %min
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test absolute difference unsigned for v2i16
|
|
define <2 x i16> @test_pdifu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pdifu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabdu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <2 x i16> @llvm.umin.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
%max = call <2 x i16> @llvm.umax.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
%res = sub <2 x i16> %max, %min
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test absolute difference signed for v4i8
|
|
define <4 x i8> @test_pdif_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pdif_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabd.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <4 x i8> @llvm.smin.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
%max = call <4 x i8> @llvm.smax.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
%res = sub <4 x i8> %max, %min
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test absolute difference unsigned for v4i8
|
|
define <4 x i8> @test_pdifu_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pdifu_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pabdu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <4 x i8> @llvm.umin.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
%max = call <4 x i8> @llvm.umax.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
%res = sub <4 x i8> %max, %min
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test averaging floor subtraction signed for v2i16
|
|
; pasub pattern: (a - b) arithmetic shift right 1
|
|
define <2 x i16> @test_pasub_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pasub_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pasub.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <2 x i16> %a to <2 x i32>
|
|
%b_ext = sext <2 x i16> %b to <2 x i32>
|
|
%sub = sub <2 x i32> %a_ext, %b_ext
|
|
%res = ashr <2 x i32> %sub, <i32 1, i32 1>
|
|
%res_trunc = trunc <2 x i32> %res to <2 x i16>
|
|
ret <2 x i16> %res_trunc
|
|
}
|
|
|
|
; Test averaging floor subtraction unsigned for v2i16
|
|
; pasubu pattern: (a - b) logical shift right 1
|
|
define <2 x i16> @test_pasubu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pasubu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pasubu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <2 x i16> %a to <2 x i32>
|
|
%b_ext = zext <2 x i16> %b to <2 x i32>
|
|
%sub = sub <2 x i32> %a_ext, %b_ext
|
|
%res = lshr <2 x i32> %sub, <i32 1, i32 1>
|
|
%res_trunc = trunc <2 x i32> %res to <2 x i16>
|
|
ret <2 x i16> %res_trunc
|
|
}
|
|
|
|
; Test averaging floor subtraction signed for v4i8
|
|
define <4 x i8> @test_pasub_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pasub_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pasub.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <4 x i8> %a to <4 x i16>
|
|
%b_ext = sext <4 x i8> %b to <4 x i16>
|
|
%sub = sub <4 x i16> %a_ext, %b_ext
|
|
%res = ashr <4 x i16> %sub, <i16 1, i16 1, i16 1, i16 1>
|
|
%res_trunc = trunc <4 x i16> %res to <4 x i8>
|
|
ret <4 x i8> %res_trunc
|
|
}
|
|
|
|
; Test averaging floor subtraction unsigned for v4i8
|
|
define <4 x i8> @test_pasubu_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_pasubu_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pasubu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <4 x i8> %a to <4 x i16>
|
|
%b_ext = zext <4 x i8> %b to <4 x i16>
|
|
%sub = sub <4 x i16> %a_ext, %b_ext
|
|
%res = lshr <4 x i16> %sub, <i16 1, i16 1, i16 1, i16 1>
|
|
%res_trunc = trunc <4 x i16> %res to <4 x i8>
|
|
ret <4 x i8> %res_trunc
|
|
}
|
|
|
|
; Test PLI (pack load immediate) for v2i16
|
|
define <2 x i16> @test_pli_h() {
|
|
; CHECK-LABEL: test_pli_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.h a0, 42
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 42)
|
|
}
|
|
|
|
define <2 x i16> @test_pli_h_negative() {
|
|
; CHECK-LABEL: test_pli_h_negative:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.h a0, -5
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 -5)
|
|
}
|
|
|
|
; Test PLI for v4i8 with unsigned immediate
|
|
define <4 x i8> @test_pli_b() {
|
|
; CHECK-LABEL: test_pli_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.b a0, 32
|
|
; CHECK-NEXT: ret
|
|
ret <4 x i8> splat (i8 32)
|
|
}
|
|
|
|
define <2 x i16> @test_pli_b_v2i16() {
|
|
; CHECK-LABEL: test_pli_b_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.b a0, 32
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 u0x2020)
|
|
}
|
|
|
|
define <4 x i8> @test_pli_b_negative() {
|
|
; CHECK-LABEL: test_pli_b_negative:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.b a0, -2
|
|
; CHECK-NEXT: ret
|
|
ret <4 x i8> splat (i8 -2)
|
|
}
|
|
|
|
define <2 x i16> @test_pli_b_negative_v2i16() {
|
|
; CHECK-LABEL: test_pli_b_negative_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pli.b a0, -2
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 u0xfefe)
|
|
}
|
|
|
|
define <2 x i16> @test_plui_h() {
|
|
; CHECK-LABEL: test_plui_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: plui.h a0, 218
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 u0x3680)
|
|
}
|
|
|
|
define <2 x i16> @test_plui_h_negative() {
|
|
; CHECK-LABEL: test_plui_h_negative:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: plui.h a0, -295
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 u0xb640)
|
|
}
|
|
|
|
define <4 x i8> @test_allones_v4i8() {
|
|
; CHECK-LABEL: test_allones_v4i8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: li a0, -1
|
|
; CHECK-NEXT: ret
|
|
ret <4 x i8> splat (i8 -1)
|
|
}
|
|
|
|
define <2 x i16> @test_allones_v2i16() {
|
|
; CHECK-LABEL: test_allones_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: li a0, -1
|
|
; CHECK-NEXT: ret
|
|
ret <2 x i16> splat (i16 -1)
|
|
}
|
|
|
|
define i16 @test_extract_vector_16(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_extract_vector_16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: ret
|
|
%extracted = extractelement <2 x i16> %a, i32 0
|
|
ret i16 %extracted
|
|
}
|
|
|
|
define i16 @test_extract_vector_16_elem1(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_extract_vector_16_elem1:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: srli a0, a0, 16
|
|
; CHECK-NEXT: ret
|
|
%extracted = extractelement <2 x i16> %a, i32 1
|
|
ret i16 %extracted
|
|
}
|
|
|
|
define i8 @test_extract_vector_8(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_extract_vector_8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: ret
|
|
%extracted = extractelement <4 x i8> %a, i32 0
|
|
ret i8 %extracted
|
|
}
|
|
|
|
define i8 @test_extract_vector_8_elem1(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_extract_vector_8_elem1:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: srli a0, a0, 8
|
|
; CHECK-NEXT: ret
|
|
%extracted = extractelement <4 x i8> %a, i32 1
|
|
ret i8 %extracted
|
|
}
|
|
|
|
define <2 x i16> @test_insert_vector_16(<2 x i16> %a, i16 %val) {
|
|
; RV32-LABEL: test_insert_vector_16:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a0, a0, 16
|
|
; RV32-NEXT: pack a0, a1, a0
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_insert_vector_16:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a0, a0, 16
|
|
; RV64-NEXT: ppaire.h a0, a1, a0
|
|
; RV64-NEXT: ret
|
|
%res = insertelement <2 x i16> %a, i16 %val, i32 0
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_insert_vector_16_elem1(<2 x i16> %a, i16 %val) {
|
|
; RV32-LABEL: test_insert_vector_16_elem1:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_insert_vector_16_elem1:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = insertelement <2 x i16> %a, i16 %val, i32 1
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_insert_vector_8(<4 x i8> %a, i8 %val) {
|
|
; RV32-LABEL: test_insert_vector_8:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: li a2, 255
|
|
; RV32-NEXT: mvm a0, a1, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_insert_vector_8:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a0, 8
|
|
; RV64-NEXT: srli a3, a0, 24
|
|
; RV64-NEXT: srli a0, a0, 16
|
|
; RV64-NEXT: ppaire.b a0, a0, a3
|
|
; RV64-NEXT: ppaire.b a1, a1, a2
|
|
; RV64-NEXT: ppaire.h a0, a1, a0
|
|
; RV64-NEXT: ret
|
|
%res = insertelement <4 x i8> %a, i8 %val, i32 0
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_insert_vector_8_elem2(<4 x i8> %a, i8 %val) {
|
|
; RV32-LABEL: test_insert_vector_8_elem2:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: slli a1, a1, 16
|
|
; RV32-NEXT: lui a2, 4080
|
|
; RV32-NEXT: mvm a0, a1, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_insert_vector_8_elem2:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a0, 8
|
|
; RV64-NEXT: srli a3, a0, 24
|
|
; RV64-NEXT: ppaire.b a1, a1, a3
|
|
; RV64-NEXT: ppaire.b a0, a0, a2
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = insertelement <4 x i8> %a, i8 %val, i32 2
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test for splat
|
|
define <4 x i8> @test_non_const_splat_i8(i8 %elt) {
|
|
; CHECK-LABEL: test_non_const_splat_i8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmv.bs a0, a0
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %elt, i32 0
|
|
%splat = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
ret <4 x i8> %splat
|
|
}
|
|
|
|
define <2 x i16> @test_non_const_splat_i16(i16 %elt) {
|
|
; CHECK-LABEL: test_non_const_splat_i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmv.hs a0, a0
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %elt, i32 0
|
|
%splat = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
ret <2 x i16> %splat
|
|
}
|
|
|
|
; Test add(vec, splat(scalar)) pattern
|
|
define <4 x i8> @test_padd_bs_splat_lhs(<4 x i8> %a, i8 %b) {
|
|
; CHECK-LABEL: test_padd_bs_splat_lhs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %b, i32 0
|
|
%splat = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = add <4 x i8> %splat, %a
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_padd_bs_splat_rhs(<4 x i8> %a, i8 %b) {
|
|
; CHECK-LABEL: test_padd_bs_splat_rhs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %b, i32 0
|
|
%splat = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = add <4 x i8> %a, %splat
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_padd_hs_splat_lhs(<2 x i16> %a, i16 %b) {
|
|
; CHECK-LABEL: test_padd_hs_splat_lhs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %b, i32 0
|
|
%splat = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = add <2 x i16> %splat, %a
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_padd_hs_splat_rhs(<2 x i16> %a, i16 %b) {
|
|
; CHECK-LABEL: test_padd_hs_splat_rhs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: padd.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %b, i32 0
|
|
%splat = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = add <2 x i16> %a, %splat
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_build_vector_i8(i8 %a, i8 %c, i8 %b, i8 %d) {
|
|
; RV32-LABEL: test_build_vector_i8:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: ppaire.db a0, a0, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_build_vector_i8:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: ppaire.b a1, a1, a3
|
|
; RV64-NEXT: ppaire.b a0, a0, a2
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%v0 = insertelement <4 x i8> poison, i8 %a, i32 0
|
|
%v1 = insertelement <4 x i8> %v0, i8 %b, i32 1
|
|
%v2 = insertelement <4 x i8> %v1, i8 %c, i32 2
|
|
%v3 = insertelement <4 x i8> %v2, i8 %d, i32 3
|
|
ret <4 x i8> %v3
|
|
}
|
|
|
|
define <2 x i16> @test_build_vector_i16(i16 %a, i16 %b) {
|
|
; RV32-LABEL: test_build_vector_i16:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_build_vector_i16:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%v0 = insertelement <2 x i16> poison, i16 %a, i32 0
|
|
%v1 = insertelement <2 x i16> %v0, i16 %b, i32 1
|
|
ret <2 x i16> %v1
|
|
}
|
|
|
|
; Test logical shift left immediate for v2i16
|
|
define <2 x i16> @test_pslli_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_pslli_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pslli.h a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = shl <2 x i16> %a, splat(i16 2)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test logical shift left immediate for v4i8
|
|
define <4 x i8> @test_pslli_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_pslli_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pslli.b a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = shl <4 x i8> %a, splat(i8 2)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test saturating shift left arithmetic with splat immediate shift amount for v2i16
|
|
define <2 x i16> @test_psslai_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_psslai_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psslai.h a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.sshl.sat.v2i16(<2 x i16> %a, <2 x i16> splat(i16 2))
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test saturating shift left arithmetic with splat immediate shift amount for v4i8
|
|
define <4 x i8> @test_psslai_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_psslai_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltz.b a1, a0
|
|
; CHECK-NEXT: pli.b a2, -128
|
|
; CHECK-NEXT: pli.b a3, 127
|
|
; CHECK-NEXT: merge a1, a3, a2
|
|
; CHECK-NEXT: pslli.b a2, a0, 2
|
|
; CHECK-NEXT: psrai.b a3, a2, 2
|
|
; CHECK-NEXT: pmseq.b a0, a0, a3
|
|
; CHECK-NEXT: merge a0, a1, a2
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.sshl.sat.v4i8(<4 x i8> %a, <4 x i8> splat(i8 2))
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test saturating shift left arithmetic with splat shift amount for v2i16
|
|
define <2 x i16> @test_pssla_hs(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_pssla_hs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pssha.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %shamt, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = call <2 x i16> @llvm.sshl.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test saturating shift left arithmetic with non-splat shift amount for v2i16
|
|
define <2 x i16> @test_pssla_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_pssla_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: sll a2, a0, a1
|
|
; RV32-NEXT: srli a3, a1, 16
|
|
; RV32-NEXT: srli a4, a0, 16
|
|
; RV32-NEXT: sext.h a5, a2
|
|
; RV32-NEXT: sra a1, a5, a1
|
|
; RV32-NEXT: pmsltz.h a5, a0
|
|
; RV32-NEXT: sll a4, a4, a3
|
|
; RV32-NEXT: pack a2, a2, a4
|
|
; RV32-NEXT: sext.h a4, a4
|
|
; RV32-NEXT: sra a3, a4, a3
|
|
; RV32-NEXT: lui a4, 8
|
|
; RV32-NEXT: pack a1, a1, a3
|
|
; RV32-NEXT: plui.h a3, -512
|
|
; RV32-NEXT: addi a4, a4, -1
|
|
; RV32-NEXT: pmv.hs a4, a4
|
|
; RV32-NEXT: pmseq.h a0, a0, a1
|
|
; RV32-NEXT: merge a5, a4, a3
|
|
; RV32-NEXT: merge a0, a5, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_pssla_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a1, 48
|
|
; RV64-NEXT: srli a3, a0, 48
|
|
; RV64-NEXT: srli a4, a1, 32
|
|
; RV64-NEXT: srli a5, a0, 32
|
|
; RV64-NEXT: sll a6, a0, a1
|
|
; RV64-NEXT: srli a7, a1, 16
|
|
; RV64-NEXT: srli t0, a0, 16
|
|
; RV64-NEXT: pmsltz.h t1, a0
|
|
; RV64-NEXT: sll a3, a3, a2
|
|
; RV64-NEXT: sll a5, a5, a4
|
|
; RV64-NEXT: sll t0, t0, a7
|
|
; RV64-NEXT: sext.h t2, a6
|
|
; RV64-NEXT: sra a1, t2, a1
|
|
; RV64-NEXT: ppaire.h t2, a5, a3
|
|
; RV64-NEXT: ppaire.h a6, a6, t0
|
|
; RV64-NEXT: pack a6, a6, t2
|
|
; RV64-NEXT: lui t2, 8
|
|
; RV64-NEXT: sext.h a3, a3
|
|
; RV64-NEXT: sra a2, a3, a2
|
|
; RV64-NEXT: plui.h a3, -512
|
|
; RV64-NEXT: addi t2, t2, -1
|
|
; RV64-NEXT: sext.h a5, a5
|
|
; RV64-NEXT: sext.h t0, t0
|
|
; RV64-NEXT: pmv.hs t2, t2
|
|
; RV64-NEXT: sra a4, a5, a4
|
|
; RV64-NEXT: sra a5, t0, a7
|
|
; RV64-NEXT: ppaire.h a2, a4, a2
|
|
; RV64-NEXT: ppaire.h a1, a1, a5
|
|
; RV64-NEXT: pack a1, a1, a2
|
|
; RV64-NEXT: pmseq.h a0, a0, a1
|
|
; RV64-NEXT: merge t1, t2, a3
|
|
; RV64-NEXT: merge a0, t1, a6
|
|
; RV64-NEXT: ret
|
|
%res = call <2 x i16> @llvm.sshl.sat.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test logical shift right immediate
|
|
define <2 x i16> @test_psrli_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_psrli_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrli.h a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = lshr <2 x i16> %a, splat(i16 2)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrli_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_psrli_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrli.b a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = lshr <4 x i8> %a, splat(i8 2)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test arithmetic shift right immediate
|
|
define <2 x i16> @test_psrai_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_psrai_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrai.h a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = ashr <2 x i16> %a, splat(i16 2)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrai_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_psrai_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrai.b a0, a0, 2
|
|
; CHECK-NEXT: ret
|
|
%res = ashr <4 x i8> %a, splat(i8 2)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test logical shift left(scalar shamt)
|
|
define <2 x i16> @test_psll_hs(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psll_hs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psll.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %shamt, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = shl <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psll_hs_mask(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psll_hs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psll.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i16 %shamt, 15
|
|
%insert = insertelement <2 x i16> poison, i16 %masked, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = shl <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psll_bs(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psll_bs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psll.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %shamt, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = shl <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psll_bs_mask(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psll_bs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psll.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i8 %shamt, 7
|
|
%insert = insertelement <4 x i8> poison, i8 %masked, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = shl <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test logical shift left(vector shamt)
|
|
define <2 x i16> @test_psll_hs_vec_shamt(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_psll_hs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: sll a2, a0, a1
|
|
; RV32-NEXT: srli a1, a1, 16
|
|
; RV32-NEXT: srli a0, a0, 16
|
|
; RV32-NEXT: sll a0, a0, a1
|
|
; RV32-NEXT: pack a0, a2, a0
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psll_hs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: sll a2, a0, a1
|
|
; RV64-NEXT: srli a1, a1, 16
|
|
; RV64-NEXT: srli a0, a0, 16
|
|
; RV64-NEXT: sll a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a2, a0
|
|
; RV64-NEXT: ret
|
|
%res = shl <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psll_bs_vec_shamt(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_psll_bs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 24
|
|
; RV32-NEXT: srli a3, a0, 24
|
|
; RV32-NEXT: srli a4, a1, 8
|
|
; RV32-NEXT: srli a5, a0, 8
|
|
; RV32-NEXT: sll a3, a3, a2
|
|
; RV32-NEXT: sll a2, a5, a4
|
|
; RV32-NEXT: sll a4, a0, a1
|
|
; RV32-NEXT: srli a1, a1, 16
|
|
; RV32-NEXT: srli a0, a0, 16
|
|
; RV32-NEXT: sll a5, a0, a1
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psll_bs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a1, 24
|
|
; RV64-NEXT: srli a3, a0, 24
|
|
; RV64-NEXT: srli a4, a1, 16
|
|
; RV64-NEXT: sll a2, a3, a2
|
|
; RV64-NEXT: srli a3, a0, 16
|
|
; RV64-NEXT: sll a3, a3, a4
|
|
; RV64-NEXT: sll a4, a0, a1
|
|
; RV64-NEXT: srli a1, a1, 8
|
|
; RV64-NEXT: srli a0, a0, 8
|
|
; RV64-NEXT: sll a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a3, a2
|
|
; RV64-NEXT: ppaire.b a0, a4, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = shl <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test logical shift right(scalar shamt)
|
|
define <2 x i16> @test_psrl_hs(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psrl_hs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrl.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %shamt, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = lshr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psrl_hs_mask(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psrl_hs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrl.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i16 %shamt, 15
|
|
%insert = insertelement <2 x i16> poison, i16 %masked, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = lshr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrl_bs(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psrl_bs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrl.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %shamt, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = lshr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrl_bs_mask(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psrl_bs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrl.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i8 %shamt, 7
|
|
%insert = insertelement <4 x i8> poison, i8 %masked, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = lshr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test arithmetic shift right(scalar shamt)
|
|
define <2 x i16> @test_psra_hs(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psra_hs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psra.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <2 x i16> poison, i16 %shamt, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = ashr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psra_hs_mask(<2 x i16> %a, i16 %shamt) {
|
|
; CHECK-LABEL: test_psra_hs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psra.hs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i16 %shamt, 15
|
|
%insert = insertelement <2 x i16> poison, i16 %masked, i32 0
|
|
%b = shufflevector <2 x i16> %insert, <2 x i16> poison, <2 x i32> zeroinitializer
|
|
%res = ashr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psra_bs(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psra_bs:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psra.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%insert = insertelement <4 x i8> poison, i8 %shamt, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = ashr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psra_bs_mask(<4 x i8> %a, i8 %shamt) {
|
|
; CHECK-LABEL: test_psra_bs_mask:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psra.bs a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%masked = and i8 %shamt, 7
|
|
%insert = insertelement <4 x i8> poison, i8 %masked, i32 0
|
|
%b = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
|
|
%res = ashr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test logical shift right(vector shamt)
|
|
define <2 x i16> @test_psrl_hs_vec_shamt(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_psrl_hs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 16
|
|
; RV32-NEXT: srli a3, a0, 16
|
|
; RV32-NEXT: zext.h a0, a0
|
|
; RV32-NEXT: srl a2, a3, a2
|
|
; RV32-NEXT: srl a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psrl_hs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a1, 16
|
|
; RV64-NEXT: srliw a3, a0, 16
|
|
; RV64-NEXT: zext.h a0, a0
|
|
; RV64-NEXT: srl a2, a3, a2
|
|
; RV64-NEXT: srl a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a0, a2
|
|
; RV64-NEXT: ret
|
|
%res = lshr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrl_bs_vec_shamt(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_psrl_bs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 24
|
|
; RV32-NEXT: srli a3, a0, 24
|
|
; RV32-NEXT: srli a4, a1, 8
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: srl a3, a3, a2
|
|
; RV32-NEXT: srli a5, a5, 24
|
|
; RV32-NEXT: srl a2, a5, a4
|
|
; RV32-NEXT: zext.b a4, a0
|
|
; RV32-NEXT: srli a5, a1, 16
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: srl a4, a4, a1
|
|
; RV32-NEXT: srli a0, a0, 24
|
|
; RV32-NEXT: srl a5, a0, a5
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psrl_bs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a1, 24
|
|
; RV64-NEXT: srliw a3, a0, 24
|
|
; RV64-NEXT: srli a4, a1, 16
|
|
; RV64-NEXT: srl a2, a3, a2
|
|
; RV64-NEXT: slli a3, a0, 40
|
|
; RV64-NEXT: srli a3, a3, 56
|
|
; RV64-NEXT: srl a3, a3, a4
|
|
; RV64-NEXT: zext.b a4, a0
|
|
; RV64-NEXT: srl a4, a4, a1
|
|
; RV64-NEXT: srli a1, a1, 8
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srli a0, a0, 56
|
|
; RV64-NEXT: srl a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a3, a2
|
|
; RV64-NEXT: ppaire.b a0, a4, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = lshr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test arithmetic shift right(vector shamt)
|
|
define <2 x i16> @test_psra_hs_vec_shamt(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_psra_hs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 16
|
|
; RV32-NEXT: srai a3, a0, 16
|
|
; RV32-NEXT: sext.h a0, a0
|
|
; RV32-NEXT: sra a2, a3, a2
|
|
; RV32-NEXT: sra a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psra_hs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: sext.h a2, a0
|
|
; RV64-NEXT: sra a2, a2, a1
|
|
; RV64-NEXT: srli a1, a1, 16
|
|
; RV64-NEXT: slli a0, a0, 32
|
|
; RV64-NEXT: srai a0, a0, 48
|
|
; RV64-NEXT: sra a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a2, a0
|
|
; RV64-NEXT: ret
|
|
%res = ashr <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psra_bs_vec_shamt(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_psra_bs_vec_shamt:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 24
|
|
; RV32-NEXT: srai a3, a0, 24
|
|
; RV32-NEXT: srli a4, a1, 8
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: sra a3, a3, a2
|
|
; RV32-NEXT: srai a5, a5, 24
|
|
; RV32-NEXT: sra a2, a5, a4
|
|
; RV32-NEXT: sext.b a4, a0
|
|
; RV32-NEXT: srli a5, a1, 16
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: sra a4, a4, a1
|
|
; RV32-NEXT: srai a0, a0, 24
|
|
; RV32-NEXT: sra a5, a0, a5
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psra_bs_vec_shamt:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srli a2, a1, 24
|
|
; RV64-NEXT: slli a3, a0, 32
|
|
; RV64-NEXT: srli a4, a1, 16
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: sra a2, a3, a2
|
|
; RV64-NEXT: slli a3, a0, 40
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: sra a3, a3, a4
|
|
; RV64-NEXT: sext.b a4, a0
|
|
; RV64-NEXT: sra a4, a4, a1
|
|
; RV64-NEXT: srli a1, a1, 8
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srai a0, a0, 56
|
|
; RV64-NEXT: sra a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a3, a2
|
|
; RV64-NEXT: ppaire.b a0, a4, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = ashr <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test packed multiply high signed for v2i16
|
|
define <2 x i16> @test_pmulh_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulh_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulh.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <2 x i16> %a to <2 x i32>
|
|
%b_ext = sext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%shift = lshr <2 x i32> %mul, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply high unsigned for v2i16
|
|
define <2 x i16> @test_pmulhu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <2 x i16> %a to <2 x i32>
|
|
%b_ext = zext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%shift = lshr <2 x i32> %mul, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply high signed-unsigned for v2i16
|
|
define <2 x i16> @test_pmulhsu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhsu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhsu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <2 x i16> %a to <2 x i32>
|
|
%b_ext = zext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%shift = lshr <2 x i32> %mul, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_pmulhsu_h_commuted(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhsu_h_commuted:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhsu.h a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <2 x i16> %a to <2 x i32>
|
|
%b_ext = sext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%shift = lshr <2 x i32> %mul, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply high rounding signed for v2i16
|
|
define <2 x i16> @test_pmulhr_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhr_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhr.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <2 x i16> %a to <2 x i32>
|
|
%b_ext = sext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%add = add <2 x i32> %mul, <i32 32768, i32 32768>
|
|
%shift = lshr <2 x i32> %add, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply high rounding unsigned for v2i16
|
|
define <2 x i16> @test_pmulhru_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhru_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhru.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <2 x i16> %a to <2 x i32>
|
|
%b_ext = zext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%add = add <2 x i32> %mul, <i32 32768, i32 32768>
|
|
%shift = lshr <2 x i32> %add, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply high rounding signed-unsigned for v2i16
|
|
define <2 x i16> @test_pmulhrsu_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhrsu_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhrsu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%a_ext = sext <2 x i16> %a to <2 x i32>
|
|
%b_ext = zext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%add = add <2 x i32> %mul, <i32 32768, i32 32768>
|
|
%shift = lshr <2 x i32> %add, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_pmulhrsu_h_commuted(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_pmulhrsu_h_commuted:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmulhrsu.h a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%a_ext = zext <2 x i16> %a to <2 x i32>
|
|
%b_ext = sext <2 x i16> %b to <2 x i32>
|
|
%mul = mul <2 x i32> %a_ext, %b_ext
|
|
%add = add <2 x i32> %mul, <i32 32768, i32 32768>
|
|
%shift = lshr <2 x i32> %add, <i32 16, i32 16>
|
|
%res = trunc <2 x i32> %shift to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply low for v2i16
|
|
define <2 x i16> @test_pmul_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_pmul_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: pwmul.h a0, a0, a1
|
|
; RV32-NEXT: pncvt.h a0, a0
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_pmul_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: pmul.w.h11 a2, a0, a1
|
|
; RV64-NEXT: pmul.w.h00 a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a0, a2
|
|
; RV64-NEXT: ret
|
|
%res = mul <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Test packed multiply low for v4i8
|
|
define <4 x i8> @test_pmul_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_pmul_b:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: pwmul.b a0, a0, a1
|
|
; RV32-NEXT: pncvt.b a0, a0
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_pmul_b:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: pmul.h.b11 a2, a0, a1
|
|
; RV64-NEXT: pmul.h.b00 a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a0, a0, a2
|
|
; RV64-NEXT: ret
|
|
%res = mul <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Division and remainder tests
|
|
define <2 x i16> @test_psdiv_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_psdiv_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srai a2, a1, 16
|
|
; RV32-NEXT: srai a3, a0, 16
|
|
; RV32-NEXT: sext.h a1, a1
|
|
; RV32-NEXT: sext.h a0, a0
|
|
; RV32-NEXT: div a2, a3, a2
|
|
; RV32-NEXT: div a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psdiv_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: sext.h a2, a1
|
|
; RV64-NEXT: sext.h a3, a0
|
|
; RV64-NEXT: slli a1, a1, 32
|
|
; RV64-NEXT: slli a0, a0, 32
|
|
; RV64-NEXT: divw a2, a3, a2
|
|
; RV64-NEXT: srai a1, a1, 48
|
|
; RV64-NEXT: srai a0, a0, 48
|
|
; RV64-NEXT: divw a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a2, a0
|
|
; RV64-NEXT: ret
|
|
%res = sdiv <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psdiv_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_psdiv_b:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srai a2, a1, 24
|
|
; RV32-NEXT: srai a3, a0, 24
|
|
; RV32-NEXT: slli a4, a1, 16
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: div a3, a3, a2
|
|
; RV32-NEXT: srai a4, a4, 24
|
|
; RV32-NEXT: srai a5, a5, 24
|
|
; RV32-NEXT: div a2, a5, a4
|
|
; RV32-NEXT: sext.b a4, a1
|
|
; RV32-NEXT: sext.b a5, a0
|
|
; RV32-NEXT: slli a1, a1, 8
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: div a4, a5, a4
|
|
; RV32-NEXT: srai a1, a1, 24
|
|
; RV32-NEXT: srai a0, a0, 24
|
|
; RV32-NEXT: div a5, a0, a1
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psdiv_b:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: slli a2, a1, 32
|
|
; RV64-NEXT: slli a3, a0, 32
|
|
; RV64-NEXT: sext.b a4, a1
|
|
; RV64-NEXT: sext.b a5, a0
|
|
; RV64-NEXT: divw a4, a5, a4
|
|
; RV64-NEXT: slli a5, a1, 40
|
|
; RV64-NEXT: srai a2, a2, 56
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: divw a2, a3, a2
|
|
; RV64-NEXT: slli a3, a0, 40
|
|
; RV64-NEXT: srai a5, a5, 56
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: divw a3, a3, a5
|
|
; RV64-NEXT: slli a1, a1, 48
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srai a1, a1, 56
|
|
; RV64-NEXT: srai a0, a0, 56
|
|
; RV64-NEXT: divw a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a3, a2
|
|
; RV64-NEXT: ppaire.b a0, a4, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = sdiv <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_pudiv_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_pudiv_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 16
|
|
; RV32-NEXT: srli a3, a0, 16
|
|
; RV32-NEXT: zext.h a1, a1
|
|
; RV32-NEXT: zext.h a0, a0
|
|
; RV32-NEXT: divu a2, a3, a2
|
|
; RV32-NEXT: divu a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_pudiv_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srliw a2, a1, 16
|
|
; RV64-NEXT: srliw a3, a0, 16
|
|
; RV64-NEXT: zext.h a1, a1
|
|
; RV64-NEXT: zext.h a0, a0
|
|
; RV64-NEXT: divuw a2, a3, a2
|
|
; RV64-NEXT: divuw a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a0, a2
|
|
; RV64-NEXT: ret
|
|
%res = udiv <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_pudiv_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_pudiv_b:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 24
|
|
; RV32-NEXT: srli a3, a0, 24
|
|
; RV32-NEXT: slli a4, a1, 16
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: divu a3, a3, a2
|
|
; RV32-NEXT: srli a4, a4, 24
|
|
; RV32-NEXT: srli a5, a5, 24
|
|
; RV32-NEXT: divu a2, a5, a4
|
|
; RV32-NEXT: zext.b a4, a1
|
|
; RV32-NEXT: zext.b a5, a0
|
|
; RV32-NEXT: slli a1, a1, 8
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: divu a4, a5, a4
|
|
; RV32-NEXT: srli a1, a1, 24
|
|
; RV32-NEXT: srli a0, a0, 24
|
|
; RV32-NEXT: divu a5, a0, a1
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_pudiv_b:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srliw a2, a1, 24
|
|
; RV64-NEXT: srliw a3, a0, 24
|
|
; RV64-NEXT: slli a4, a1, 40
|
|
; RV64-NEXT: zext.b a5, a1
|
|
; RV64-NEXT: divuw a2, a3, a2
|
|
; RV64-NEXT: zext.b a3, a0
|
|
; RV64-NEXT: divuw a3, a3, a5
|
|
; RV64-NEXT: slli a5, a0, 40
|
|
; RV64-NEXT: srli a4, a4, 56
|
|
; RV64-NEXT: srli a5, a5, 56
|
|
; RV64-NEXT: divuw a4, a5, a4
|
|
; RV64-NEXT: slli a1, a1, 48
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srli a1, a1, 56
|
|
; RV64-NEXT: srli a0, a0, 56
|
|
; RV64-NEXT: divuw a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a4, a2
|
|
; RV64-NEXT: ppaire.b a0, a3, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = udiv <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_psrem_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_psrem_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srai a2, a1, 16
|
|
; RV32-NEXT: srai a3, a0, 16
|
|
; RV32-NEXT: sext.h a1, a1
|
|
; RV32-NEXT: sext.h a0, a0
|
|
; RV32-NEXT: rem a2, a3, a2
|
|
; RV32-NEXT: rem a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psrem_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: sext.h a2, a1
|
|
; RV64-NEXT: sext.h a3, a0
|
|
; RV64-NEXT: slli a1, a1, 32
|
|
; RV64-NEXT: slli a0, a0, 32
|
|
; RV64-NEXT: remw a2, a3, a2
|
|
; RV64-NEXT: srai a1, a1, 48
|
|
; RV64-NEXT: srai a0, a0, 48
|
|
; RV64-NEXT: remw a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a2, a0
|
|
; RV64-NEXT: ret
|
|
%res = srem <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_psrem_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_psrem_b:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srai a2, a1, 24
|
|
; RV32-NEXT: srai a3, a0, 24
|
|
; RV32-NEXT: slli a4, a1, 16
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: rem a3, a3, a2
|
|
; RV32-NEXT: srai a4, a4, 24
|
|
; RV32-NEXT: srai a5, a5, 24
|
|
; RV32-NEXT: rem a2, a5, a4
|
|
; RV32-NEXT: sext.b a4, a1
|
|
; RV32-NEXT: sext.b a5, a0
|
|
; RV32-NEXT: slli a1, a1, 8
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: rem a4, a5, a4
|
|
; RV32-NEXT: srai a1, a1, 24
|
|
; RV32-NEXT: srai a0, a0, 24
|
|
; RV32-NEXT: rem a5, a0, a1
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_psrem_b:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: slli a2, a1, 32
|
|
; RV64-NEXT: slli a3, a0, 32
|
|
; RV64-NEXT: sext.b a4, a1
|
|
; RV64-NEXT: sext.b a5, a0
|
|
; RV64-NEXT: remw a4, a5, a4
|
|
; RV64-NEXT: slli a5, a1, 40
|
|
; RV64-NEXT: srai a2, a2, 56
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: remw a2, a3, a2
|
|
; RV64-NEXT: slli a3, a0, 40
|
|
; RV64-NEXT: srai a5, a5, 56
|
|
; RV64-NEXT: srai a3, a3, 56
|
|
; RV64-NEXT: remw a3, a3, a5
|
|
; RV64-NEXT: slli a1, a1, 48
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srai a1, a1, 56
|
|
; RV64-NEXT: srai a0, a0, 56
|
|
; RV64-NEXT: remw a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a3, a2
|
|
; RV64-NEXT: ppaire.b a0, a4, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = srem <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_purem_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; RV32-LABEL: test_purem_h:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 16
|
|
; RV32-NEXT: srli a3, a0, 16
|
|
; RV32-NEXT: zext.h a1, a1
|
|
; RV32-NEXT: zext.h a0, a0
|
|
; RV32-NEXT: remu a2, a3, a2
|
|
; RV32-NEXT: remu a0, a0, a1
|
|
; RV32-NEXT: pack a0, a0, a2
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_purem_h:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srliw a2, a1, 16
|
|
; RV64-NEXT: srliw a3, a0, 16
|
|
; RV64-NEXT: zext.h a1, a1
|
|
; RV64-NEXT: zext.h a0, a0
|
|
; RV64-NEXT: remuw a2, a3, a2
|
|
; RV64-NEXT: remuw a0, a0, a1
|
|
; RV64-NEXT: ppaire.h a0, a0, a2
|
|
; RV64-NEXT: ret
|
|
%res = urem <2 x i16> %a, %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_purem_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; RV32-LABEL: test_purem_b:
|
|
; RV32: # %bb.0:
|
|
; RV32-NEXT: srli a2, a1, 24
|
|
; RV32-NEXT: srli a3, a0, 24
|
|
; RV32-NEXT: slli a4, a1, 16
|
|
; RV32-NEXT: slli a5, a0, 16
|
|
; RV32-NEXT: remu a3, a3, a2
|
|
; RV32-NEXT: srli a4, a4, 24
|
|
; RV32-NEXT: srli a5, a5, 24
|
|
; RV32-NEXT: remu a2, a5, a4
|
|
; RV32-NEXT: zext.b a4, a1
|
|
; RV32-NEXT: zext.b a5, a0
|
|
; RV32-NEXT: slli a1, a1, 8
|
|
; RV32-NEXT: slli a0, a0, 8
|
|
; RV32-NEXT: remu a4, a5, a4
|
|
; RV32-NEXT: srli a1, a1, 24
|
|
; RV32-NEXT: srli a0, a0, 24
|
|
; RV32-NEXT: remu a5, a0, a1
|
|
; RV32-NEXT: ppaire.db a0, a4, a2
|
|
; RV32-NEXT: pack a0, a0, a1
|
|
; RV32-NEXT: ret
|
|
;
|
|
; RV64-LABEL: test_purem_b:
|
|
; RV64: # %bb.0:
|
|
; RV64-NEXT: srliw a2, a1, 24
|
|
; RV64-NEXT: srliw a3, a0, 24
|
|
; RV64-NEXT: slli a4, a1, 40
|
|
; RV64-NEXT: zext.b a5, a1
|
|
; RV64-NEXT: remuw a2, a3, a2
|
|
; RV64-NEXT: zext.b a3, a0
|
|
; RV64-NEXT: remuw a3, a3, a5
|
|
; RV64-NEXT: slli a5, a0, 40
|
|
; RV64-NEXT: srli a4, a4, 56
|
|
; RV64-NEXT: srli a5, a5, 56
|
|
; RV64-NEXT: remuw a4, a5, a4
|
|
; RV64-NEXT: slli a1, a1, 48
|
|
; RV64-NEXT: slli a0, a0, 48
|
|
; RV64-NEXT: srli a1, a1, 56
|
|
; RV64-NEXT: srli a0, a0, 56
|
|
; RV64-NEXT: remuw a0, a0, a1
|
|
; RV64-NEXT: ppaire.b a1, a4, a2
|
|
; RV64-NEXT: ppaire.b a0, a3, a0
|
|
; RV64-NEXT: ppaire.h a0, a0, a1
|
|
; RV64-NEXT: ret
|
|
%res = urem <4 x i8> %a, %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Comparison operations for v2i16
|
|
define <2 x i16> @test_eq_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_eq_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmseq.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp eq <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_ne_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_ne_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmseq.h a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ne <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_nez_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_nez_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsnez.h a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ne <2 x i16> %a, splat (i16 0)
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_slt_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_slt_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp slt <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_sle_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_sle_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.h a0, a1, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sle <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_sgt_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_sgt_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.h a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sgt <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_sge_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_sge_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.h a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sge <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_sgez_h(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_sgez_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltz.h a0, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sgt <2 x i16> %a, splat (i16 -1);
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_ult_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_ult_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ult <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_ule_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_ule_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.h a0, a1, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ule <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_ugt_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_ugt_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.h a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ugt <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <2 x i16> @test_uge_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_uge_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.h a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp uge <2 x i16> %a, %b
|
|
%res = sext <2 x i1> %cmp to <2 x i16>
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
; Comparison operations for v4i8
|
|
define <4 x i8> @test_eq_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_eq_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmseq.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp eq <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_ne_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_ne_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmseq.b a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ne <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_nez_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_nez_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsnez.b a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ne <4 x i8> %a, splat (i8 0)
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_slt_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_slt_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp slt <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_sle_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_sle_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.b a0, a1, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sle <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_sgt_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_sgt_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.b a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sgt <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_sge_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_sge_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.b a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sge <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_sgez_b(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_sgez_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltz.b a0, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp sgt <4 x i8> %a, splat (i8 -1)
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_ult_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_ult_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ult <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_ule_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_ule_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.b a0, a1, a0
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ule <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_ugt_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_ugt_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.b a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp ugt <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <4 x i8> @test_uge_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_uge_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmsltu.b a0, a0, a1
|
|
; CHECK-NEXT: not a0, a0
|
|
; CHECK-NEXT: ret
|
|
%cmp = icmp uge <4 x i8> %a, %b
|
|
%res = sext <4 x i1> %cmp to <4 x i8>
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test 8/16-bit [s|u]min/[s|u]max
|
|
define <2 x i16> @test_smin_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_smin_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmin.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <2 x i16> @llvm.smin.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %min
|
|
}
|
|
|
|
define <2 x i16> @test_umin_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_umin_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pminu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <2 x i16> @llvm.umin.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %min
|
|
}
|
|
|
|
define <4 x i8> @test_smin_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_smin_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmin.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <4 x i8> @llvm.smin.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %min
|
|
}
|
|
|
|
define <4 x i8> @test_umin_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_umin_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pminu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%min = call <4 x i8> @llvm.umin.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %min
|
|
}
|
|
|
|
define <2 x i16> @test_smax_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_smax_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmax.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%max = call <2 x i16> @llvm.smax.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %max
|
|
}
|
|
|
|
define <2 x i16> @test_umax_h(<2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_umax_h:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmaxu.h a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%max = call <2 x i16> @llvm.umax.v2i16(<2 x i16> %a, <2 x i16> %b)
|
|
ret <2 x i16> %max
|
|
}
|
|
|
|
define <4 x i8> @test_smax_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_smax_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmax.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%max = call <4 x i8> @llvm.smax.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %max
|
|
}
|
|
|
|
define <4 x i8> @test_umax_b(<4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_umax_b:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmaxu.b a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%max = call <4 x i8> @llvm.umax.v4i8(<4 x i8> %a, <4 x i8> %b)
|
|
ret <4 x i8> %max
|
|
}
|
|
|
|
; Test select operations
|
|
define <2 x i16> @test_select_v2i16(i1 %cond, <2 x i16> %a, <2 x i16> %b) {
|
|
; CHECK-LABEL: test_select_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: andi a3, a0, 1
|
|
; CHECK-NEXT: mv a0, a1
|
|
; CHECK-NEXT: bnez a3, .LBB144_2
|
|
; CHECK-NEXT: # %bb.1:
|
|
; CHECK-NEXT: mv a0, a2
|
|
; CHECK-NEXT: .LBB144_2:
|
|
; CHECK-NEXT: ret
|
|
%res = select i1 %cond, <2 x i16> %a, <2 x i16> %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_select_v4i8(i1 %cond, <4 x i8> %a, <4 x i8> %b) {
|
|
; CHECK-LABEL: test_select_v4i8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: andi a3, a0, 1
|
|
; CHECK-NEXT: mv a0, a1
|
|
; CHECK-NEXT: bnez a3, .LBB145_2
|
|
; CHECK-NEXT: # %bb.1:
|
|
; CHECK-NEXT: mv a0, a2
|
|
; CHECK-NEXT: .LBB145_2:
|
|
; CHECK-NEXT: ret
|
|
%res = select i1 %cond, <4 x i8> %a, <4 x i8> %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
; Test vselect operations
|
|
define <2 x i16> @test_vselect_v2i16(<2 x i16> %a, <2 x i16> %b, <2 x i16> %c) {
|
|
; CHECK-LABEL: test_vselect_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmslt.h a0, a1, a0
|
|
; CHECK-NEXT: merge a0, a1, a2
|
|
; CHECK-NEXT: ret
|
|
%mask = icmp sgt <2 x i16> %a, %b
|
|
%res = select <2 x i1> %mask, <2 x i16> %c, <2 x i16> %b
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_vselect_v4i8(<4 x i8> %a, <4 x i8> %b, <4 x i8> %c) {
|
|
; CHECK-LABEL: test_vselect_v4i8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: pmseq.b a0, a0, a1
|
|
; CHECK-NEXT: merge a0, a1, a2
|
|
; CHECK-NEXT: ret
|
|
%mask = icmp eq <4 x i8> %a, %b
|
|
%res = select <4 x i1> %mask, <4 x i8> %c, <4 x i8> %b
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_bswap_v2i16(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_bswap_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrli.h a1, a0, 8
|
|
; CHECK-NEXT: pslli.h a0, a0, 8
|
|
; CHECK-NEXT: or a0, a0, a1
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %a)
|
|
ret <2 x i16> %res
|
|
}
|
|
|
|
define <4 x i8> @test_bitreverse_v4i8(<4 x i8> %a) {
|
|
; CHECK-LABEL: test_bitreverse_v4i8:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrli.b a1, a0, 4
|
|
; CHECK-NEXT: pli.b a2, 15
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: pli.b a2, 51
|
|
; CHECK-NEXT: pslli.b a0, a0, 4
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: psrli.b a1, a0, 2
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: pli.b a2, 85
|
|
; CHECK-NEXT: pslli.b a0, a0, 2
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: psrli.b a1, a0, 1
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: pslli.b a0, a0, 1
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%res = call <4 x i8> @llvm.bitreverse.v4i8(<4 x i8> %a)
|
|
ret <4 x i8> %res
|
|
}
|
|
|
|
define <2 x i16> @test_bitreverse_v2i16(<2 x i16> %a) {
|
|
; CHECK-LABEL: test_bitreverse_v2i16:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: psrli.h a1, a0, 8
|
|
; CHECK-NEXT: pslli.h a0, a0, 8
|
|
; CHECK-NEXT: pli.b a2, 15
|
|
; CHECK-NEXT: or a0, a0, a1
|
|
; CHECK-NEXT: psrli.h a1, a0, 4
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: pli.b a2, 51
|
|
; CHECK-NEXT: pslli.h a0, a0, 4
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: psrli.h a1, a0, 2
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: pli.b a2, 85
|
|
; CHECK-NEXT: pslli.h a0, a0, 2
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: psrli.h a1, a0, 1
|
|
; CHECK-NEXT: and a0, a0, a2
|
|
; CHECK-NEXT: and a1, a1, a2
|
|
; CHECK-NEXT: pslli.h a0, a0, 1
|
|
; CHECK-NEXT: or a0, a1, a0
|
|
; CHECK-NEXT: ret
|
|
%res = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a)
|
|
ret <2 x i16> %res
|
|
}
|