forked from OSchip/llvm-project
81 lines
3.6 KiB
LLVM
81 lines
3.6 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
|
|
|
define <4 x i32> @const_folding(<4 x i32> %x) {
|
|
; CHECK-LABEL: @const_folding(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> zeroinitializer, <4 x i32> <i32 5, i32 4, i32 5, i32 4>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> %x, <4 x i32> zeroinitializer, <4 x i32> <i32 5, i32 4, i32 5, i32 4>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @splat_operand(<4 x i32> %x) {
|
|
; CHECK-LABEL: @splat_operand(
|
|
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[SPLAT]], <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 1>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%splat = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> zeroinitializer
|
|
%shuf = shufflevector <4 x i32> %splat, <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 1>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @undef_mask(<4 x i32> %x) {
|
|
; CHECK-LABEL: @undef_mask(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> undef
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> undef
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @identity_mask_0(<4 x i32> %x) {
|
|
; CHECK-LABEL: @identity_mask_0(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @identity_mask_1(<4 x i32> %x) {
|
|
; CHECK-LABEL: @identity_mask_1(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> undef, <4 x i32> [[X:%.*]], <4 x i32> <i32 4, i32 5, i32 6, i32 7>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> undef, <4 x i32> %x, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @pseudo_identity_mask(<4 x i32> %x) {
|
|
; CHECK-LABEL: @pseudo_identity_mask(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> [[X]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> %x, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @const_operand(<4 x i32> %x) {
|
|
; CHECK-LABEL: @const_operand(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> <i32 42, i32 43, i32 44, i32 45>, <4 x i32> [[X:%.*]], <4 x i32> <i32 0, i32 3, i32 2, i32 1>
|
|
; CHECK-NEXT: ret <4 x i32> [[SHUF]]
|
|
;
|
|
%shuf = shufflevector <4 x i32> <i32 42, i32 43, i32 44, i32 45>, <4 x i32> %x, <4 x i32> <i32 0, i32 3, i32 2, i32 1>
|
|
ret <4 x i32> %shuf
|
|
}
|
|
|
|
define <4 x i32> @merge(<4 x i32> %x) {
|
|
; CHECK-LABEL: @merge(
|
|
; CHECK-NEXT: [[LOWER:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <2 x i32> <i32 1, i32 0>
|
|
; CHECK-NEXT: [[UPPER:%.*]] = shufflevector <4 x i32> [[X]], <4 x i32> undef, <2 x i32> <i32 2, i32 3>
|
|
; CHECK-NEXT: [[MERGED:%.*]] = shufflevector <2 x i32> [[UPPER]], <2 x i32> [[LOWER]], <4 x i32> <i32 3, i32 2, i32 0, i32 1>
|
|
; CHECK-NEXT: ret <4 x i32> [[MERGED]]
|
|
;
|
|
%lower = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 1, i32 0>
|
|
%upper = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 2, i32 3>
|
|
%merged = shufflevector <2 x i32> %upper, <2 x i32> %lower, <4 x i32> <i32 3, i32 2, i32 0, i32 1>
|
|
ret <4 x i32> %merged
|
|
}
|