[llvm] 32cc7d3 - [InstCombine] add tests for insertelts of truncs; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 11:18:29 PST 2022
Author: Sanjay Patel
Date: 2022-12-08T14:16:46-05:00
New Revision: 32cc7d3497507c6e6a150d7cbd58308f9a1558b4
URL: https://github.com/llvm/llvm-project/commit/32cc7d3497507c6e6a150d7cbd58308f9a1558b4
DIFF: https://github.com/llvm/llvm-project/commit/32cc7d3497507c6e6a150d7cbd58308f9a1558b4.diff
LOG: [InstCombine] add tests for insertelts of truncs; NFC
Added:
llvm/test/Transforms/InstCombine/insertelt-trunc.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/insertelt-trunc.ll b/llvm/test/Transforms/InstCombine/insertelt-trunc.ll
new file mode 100644
index 000000000000..12b944711f70
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/insertelt-trunc.ll
@@ -0,0 +1,208 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=instcombine -S -data-layout="E" | FileCheck %s --check-prefixes=ALL
+; RUN: opt < %s -passes=instcombine -S -data-layout="e" | FileCheck %s --check-prefixes=ALL
+
+
+define <4 x i16> @insert_01_poison_v4i16(i32 %x) {
+; ALL-LABEL: @insert_01_poison_v4i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i16> poison, i16 [[LO16]], i64 0
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i16> [[INS0]], i16 [[HI16]], i64 1
+; ALL-NEXT: ret <4 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <4 x i16> poison, i16 %lo16, i64 0
+ %ins1 = insertelement <4 x i16> %ins0, i16 %hi16, i64 1
+ ret <4 x i16> %ins1
+}
+
+define <8 x i16> @insert_10_poison_v8i16(i32 %x) {
+; ALL-LABEL: @insert_10_poison_v8i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <8 x i16> poison, i16 [[LO16]], i64 1
+; ALL-NEXT: [[INS1:%.*]] = insertelement <8 x i16> [[INS0]], i16 [[HI16]], i64 0
+; ALL-NEXT: ret <8 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <8 x i16> poison, i16 %lo16, i64 1
+ %ins1 = insertelement <8 x i16> %ins0, i16 %hi16, i64 0
+ ret <8 x i16> %ins1
+}
+
+define <4 x i32> @insert_12_poison_v4i32(i64 %x) {
+; ALL-LABEL: @insert_12_poison_v4i32(
+; ALL-NEXT: [[HI64:%.*]] = lshr i64 [[X:%.*]], 32
+; ALL-NEXT: [[HI32:%.*]] = trunc i64 [[HI64]] to i32
+; ALL-NEXT: [[LO32:%.*]] = trunc i64 [[X]] to i32
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i32> poison, i32 [[LO32]], i64 1
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i32> [[INS0]], i32 [[HI32]], i64 2
+; ALL-NEXT: ret <4 x i32> [[INS1]]
+;
+ %hi64 = lshr i64 %x, 32
+ %hi32 = trunc i64 %hi64 to i32
+ %lo32 = trunc i64 %x to i32
+ %ins0 = insertelement <4 x i32> poison, i32 %lo32, i64 1
+ %ins1 = insertelement <4 x i32> %ins0, i32 %hi32, i64 2
+ ret <4 x i32> %ins1
+}
+
+define <4 x i16> @insert_21_poison_v4i16(i32 %x) {
+; ALL-LABEL: @insert_21_poison_v4i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i16> poison, i16 [[LO16]], i64 2
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i16> [[INS0]], i16 [[HI16]], i64 1
+; ALL-NEXT: ret <4 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <4 x i16> poison, i16 %lo16, i64 2
+ %ins1 = insertelement <4 x i16> %ins0, i16 %hi16, i64 1
+ ret <4 x i16> %ins1
+}
+
+define <4 x i32> @insert_23_poison_v4i32(i64 %x) {
+; ALL-LABEL: @insert_23_poison_v4i32(
+; ALL-NEXT: [[HI64:%.*]] = lshr i64 [[X:%.*]], 32
+; ALL-NEXT: [[HI32:%.*]] = trunc i64 [[HI64]] to i32
+; ALL-NEXT: [[LO32:%.*]] = trunc i64 [[X]] to i32
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i32> poison, i32 [[LO32]], i64 2
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i32> [[INS0]], i32 [[HI32]], i64 3
+; ALL-NEXT: ret <4 x i32> [[INS1]]
+;
+ %hi64 = lshr i64 %x, 32
+ %hi32 = trunc i64 %hi64 to i32
+ %lo32 = trunc i64 %x to i32
+ %ins0 = insertelement <4 x i32> poison, i32 %lo32, i64 2
+ %ins1 = insertelement <4 x i32> %ins0, i32 %hi32, i64 3
+ ret <4 x i32> %ins1
+}
+
+define <4 x i16> @insert_32_poison_v4i16(i32 %x) {
+; ALL-LABEL: @insert_32_poison_v4i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i16> poison, i16 [[LO16]], i64 3
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i16> [[INS0]], i16 [[HI16]], i64 2
+; ALL-NEXT: ret <4 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <4 x i16> poison, i16 %lo16, i64 3
+ %ins1 = insertelement <4 x i16> %ins0, i16 %hi16, i64 2
+ ret <4 x i16> %ins1
+}
+
+define <2 x i16> @insert_01_v2i16(i32 %x, <2 x i16> %v) {
+; ALL-LABEL: @insert_01_v2i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <2 x i16> poison, i16 [[LO16]], i64 0
+; ALL-NEXT: [[INS1:%.*]] = insertelement <2 x i16> [[INS0]], i16 [[HI16]], i64 1
+; ALL-NEXT: ret <2 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <2 x i16> %v, i16 %lo16, i64 0
+ %ins1 = insertelement <2 x i16> %ins0, i16 %hi16, i64 1
+ ret <2 x i16> %ins1
+}
+
+define <8 x i16> @insert_10_v8i16(i32 %x, <8 x i16> %v) {
+; ALL-LABEL: @insert_10_v8i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <8 x i16> [[V:%.*]], i16 [[LO16]], i64 1
+; ALL-NEXT: [[INS1:%.*]] = insertelement <8 x i16> [[INS0]], i16 [[HI16]], i64 0
+; ALL-NEXT: ret <8 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <8 x i16> %v, i16 %lo16, i64 1
+ %ins1 = insertelement <8 x i16> %ins0, i16 %hi16, i64 0
+ ret <8 x i16> %ins1
+}
+
+define <4 x i32> @insert_12_v4i32(i64 %x, <4 x i32> %v) {
+; ALL-LABEL: @insert_12_v4i32(
+; ALL-NEXT: [[HI64:%.*]] = lshr i64 [[X:%.*]], 32
+; ALL-NEXT: [[HI32:%.*]] = trunc i64 [[HI64]] to i32
+; ALL-NEXT: [[LO32:%.*]] = trunc i64 [[X]] to i32
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[LO32]], i64 1
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i32> [[INS0]], i32 [[HI32]], i64 2
+; ALL-NEXT: ret <4 x i32> [[INS1]]
+;
+ %hi64 = lshr i64 %x, 32
+ %hi32 = trunc i64 %hi64 to i32
+ %lo32 = trunc i64 %x to i32
+ %ins0 = insertelement <4 x i32> %v, i32 %lo32, i64 1
+ %ins1 = insertelement <4 x i32> %ins0, i32 %hi32, i64 2
+ ret <4 x i32> %ins1
+}
+
+define <4 x i16> @insert_21_v4i16(i32 %x, <4 x i16> %v) {
+; ALL-LABEL: @insert_21_v4i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i16> [[V:%.*]], i16 [[LO16]], i64 2
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i16> [[INS0]], i16 [[HI16]], i64 1
+; ALL-NEXT: ret <4 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <4 x i16> %v, i16 %lo16, i64 2
+ %ins1 = insertelement <4 x i16> %ins0, i16 %hi16, i64 1
+ ret <4 x i16> %ins1
+}
+
+define <4 x i32> @insert_23_v4i32(i64 %x, <4 x i32> %v) {
+; ALL-LABEL: @insert_23_v4i32(
+; ALL-NEXT: [[HI64:%.*]] = lshr i64 [[X:%.*]], 32
+; ALL-NEXT: [[HI32:%.*]] = trunc i64 [[HI64]] to i32
+; ALL-NEXT: [[LO32:%.*]] = trunc i64 [[X]] to i32
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[LO32]], i64 2
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i32> [[INS0]], i32 [[HI32]], i64 3
+; ALL-NEXT: ret <4 x i32> [[INS1]]
+;
+ %hi64 = lshr i64 %x, 32
+ %hi32 = trunc i64 %hi64 to i32
+ %lo32 = trunc i64 %x to i32
+ %ins0 = insertelement <4 x i32> %v, i32 %lo32, i64 2
+ %ins1 = insertelement <4 x i32> %ins0, i32 %hi32, i64 3
+ ret <4 x i32> %ins1
+}
+
+define <4 x i16> @insert_32_v4i16(i32 %x, <4 x i16> %v) {
+; ALL-LABEL: @insert_32_v4i16(
+; ALL-NEXT: [[HI32:%.*]] = lshr i32 [[X:%.*]], 16
+; ALL-NEXT: [[HI16:%.*]] = trunc i32 [[HI32]] to i16
+; ALL-NEXT: [[LO16:%.*]] = trunc i32 [[X]] to i16
+; ALL-NEXT: [[INS0:%.*]] = insertelement <4 x i16> [[V:%.*]], i16 [[LO16]], i64 3
+; ALL-NEXT: [[INS1:%.*]] = insertelement <4 x i16> [[INS0]], i16 [[HI16]], i64 2
+; ALL-NEXT: ret <4 x i16> [[INS1]]
+;
+ %hi32 = lshr i32 %x, 16
+ %hi16 = trunc i32 %hi32 to i16
+ %lo16 = trunc i32 %x to i16
+ %ins0 = insertelement <4 x i16> %v, i16 %lo16, i64 3
+ %ins1 = insertelement <4 x i16> %ins0, i16 %hi16, i64 2
+ ret <4 x i16> %ins1
+}
More information about the llvm-commits
mailing list