blob: 49b1c84a071a55f01219a9541cacb32df954e19f [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
; The only in-range index into a one-element vector is 0, so the shuffle is
; its source.
define <1 x i32> @one_element(<1 x i32> %v, <1 x i32> %m) {
; CHECK-LABEL: define <1 x i32> @one_element(
; CHECK-SAME: <1 x i32> [[V:%.*]], <1 x i32> [[M:%.*]]) {
; CHECK-NEXT: ret <1 x i32> [[V]]
;
%r = call <1 x i32> @llvm.vector.shuffle.v1i32.v1i32(<1 x i32> %v, <1 x i32> %m)
ret <1 x i32> %r
}
define <1 x double> @one_element_fp_i8_mask(<1 x double> %v, <1 x i8> %m) {
; CHECK-LABEL: define <1 x double> @one_element_fp_i8_mask(
; CHECK-SAME: <1 x double> [[V:%.*]], <1 x i8> [[M:%.*]]) {
; CHECK-NEXT: ret <1 x double> [[V]]
;
%r = call <1 x double> @llvm.vector.shuffle.v1f64.v1i8(<1 x double> %v, <1 x i8> %m)
ret <1 x double> %r
}
; Negative test: two elements.
define <2 x i32> @two_elements(<2 x i32> %v, <2 x i32> %m) {
; CHECK-LABEL: define <2 x i32> @two_elements(
; CHECK-SAME: <2 x i32> [[V:%.*]], <2 x i32> [[M:%.*]]) {
; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.vector.shuffle.v2i32.v2i32(<2 x i32> [[V]], <2 x i32> [[M]])
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%r = call <2 x i32> @llvm.vector.shuffle.v2i32.v2i32(<2 x i32> %v, <2 x i32> %m)
ret <2 x i32> %r
}
; Negative test: a scalable vector may have more than one element.
define <vscale x 1 x i32> @scalable_one_element(<vscale x 1 x i32> %v, <vscale x 1 x i32> %m) {
; CHECK-LABEL: define <vscale x 1 x i32> @scalable_one_element(
; CHECK-SAME: <vscale x 1 x i32> [[V:%.*]], <vscale x 1 x i32> [[M:%.*]]) {
; CHECK-NEXT: [[R:%.*]] = call <vscale x 1 x i32> @llvm.vector.shuffle.nxv1i32.nxv1i32(<vscale x 1 x i32> [[V]], <vscale x 1 x i32> [[M]])
; CHECK-NEXT: ret <vscale x 1 x i32> [[R]]
;
%r = call <vscale x 1 x i32> @llvm.vector.shuffle.nxv1i32.nxv1i32(<vscale x 1 x i32> %v, <vscale x 1 x i32> %m)
ret <vscale x 1 x i32> %r
}
; A poison mask selects poison in every lane.
define <4 x i32> @poison_mask(<4 x i32> %v) {
; CHECK-LABEL: define <4 x i32> @poison_mask(
; CHECK-SAME: <4 x i32> [[V:%.*]]) {
; CHECK-NEXT: ret <4 x i32> poison
;
%r = call <4 x i32> @llvm.vector.shuffle.v4i32.v4i8(<4 x i32> %v, <4 x i8> poison)
ret <4 x i32> %r
}
define <vscale x 4 x i32> @scalable_poison_mask(<vscale x 4 x i32> %v) {
; CHECK-LABEL: define <vscale x 4 x i32> @scalable_poison_mask(
; CHECK-SAME: <vscale x 4 x i32> [[V:%.*]]) {
; CHECK-NEXT: ret <vscale x 4 x i32> poison
;
%r = call <vscale x 4 x i32> @llvm.vector.shuffle.nxv4i32.nxv4i8(<vscale x 4 x i32> %v, <vscale x 4 x i8> poison)
ret <vscale x 4 x i32> %r
}