[llvm] 3cb5aa8 - [InstCombine] add tests for insertelement with cast ops; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 9 11:58:46 PDT 2021
Author: Sanjay Patel
Date: 2021-09-09T14:58:39-04:00
New Revision: 3cb5aa8622226548483a6d997798614c09b0dc7a
URL: https://github.com/llvm/llvm-project/commit/3cb5aa8622226548483a6d997798614c09b0dc7a
DIFF: https://github.com/llvm/llvm-project/commit/3cb5aa8622226548483a6d997798614c09b0dc7a.diff
LOG: [InstCombine] add tests for insertelement with cast ops; NFC
Added:
llvm/test/Transforms/InstCombine/insert-ext.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/insert-ext.ll b/llvm/test/Transforms/InstCombine/insert-ext.ll
new file mode 100644
index 0000000000000..2367171055d91
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/insert-ext.ll
@@ -0,0 +1,130 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare void @use(i32)
+declare void @usevec(<2 x i32>)
+
+define <2 x double> @fpext_fpext(<2 x half> %x, half %y, i32 %index) {
+; CHECK-LABEL: @fpext_fpext(
+; CHECK-NEXT: [[V:%.*]] = fpext <2 x half> [[X:%.*]] to <2 x double>
+; CHECK-NEXT: [[S:%.*]] = fpext half [[Y:%.*]] to double
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x double> [[V]], double [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x double> [[I]]
+;
+ %v = fpext <2 x half> %x to <2 x double>
+ %s = fpext half %y to double
+ %i = insertelement <2 x double> %v, double %s, i32 %index
+ ret <2 x double> %i
+}
+
+define <2 x i32> @sext_sext(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @sext_sext(
+; CHECK-NEXT: [[V:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[Y:%.*]] to i32
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[I]]
+;
+ %v = sext <2 x i8> %x to <2 x i32>
+ %s = sext i8 %y to i32
+ %i = insertelement <2 x i32> %v, i32 %s, i32 %index
+ ret <2 x i32> %i
+}
+
+define <2 x i12> @zext_zext(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @zext_zext(
+; CHECK-NEXT: [[V:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i12>
+; CHECK-NEXT: [[S:%.*]] = zext i8 [[Y:%.*]] to i12
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i12> [[V]], i12 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i12> [[I]]
+;
+ %v = zext <2 x i8> %x to <2 x i12>
+ %s = zext i8 %y to i12
+ %i = insertelement <2 x i12> %v, i12 %s, i32 %index
+ ret <2 x i12> %i
+}
+
+define <2 x double> @fpext_fpext_types(<2 x half> %x, float %y, i32 %index) {
+; CHECK-LABEL: @fpext_fpext_types(
+; CHECK-NEXT: [[V:%.*]] = fpext <2 x half> [[X:%.*]] to <2 x double>
+; CHECK-NEXT: [[S:%.*]] = fpext float [[Y:%.*]] to double
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x double> [[V]], double [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x double> [[I]]
+;
+ %v = fpext <2 x half> %x to <2 x double>
+ %s = fpext float %y to double
+ %i = insertelement <2 x double> %v, double %s, i32 %index
+ ret <2 x double> %i
+}
+
+define <2 x i32> @sext_sext_types(<2 x i16> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @sext_sext_types(
+; CHECK-NEXT: [[V:%.*]] = sext <2 x i16> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[Y:%.*]] to i32
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[I]]
+;
+ %v = sext <2 x i16> %x to <2 x i32>
+ %s = sext i8 %y to i32
+ %i = insertelement <2 x i32> %v, i32 %s, i32 %index
+ ret <2 x i32> %i
+}
+
+define <2 x i12> @sext_zext(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @sext_zext(
+; CHECK-NEXT: [[V:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i12>
+; CHECK-NEXT: [[S:%.*]] = zext i8 [[Y:%.*]] to i12
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i12> [[V]], i12 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i12> [[I]]
+;
+ %v = sext <2 x i8> %x to <2 x i12>
+ %s = zext i8 %y to i12
+ %i = insertelement <2 x i12> %v, i12 %s, i32 %index
+ ret <2 x i12> %i
+}
+
+define <2 x i32> @sext_sext_use1(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @sext_sext_use1(
+; CHECK-NEXT: [[V:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: call void @usevec(<2 x i32> [[V]])
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[Y:%.*]] to i32
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[I]]
+;
+ %v = sext <2 x i8> %x to <2 x i32>
+ call void @usevec(<2 x i32> %v)
+ %s = sext i8 %y to i32
+ %i = insertelement <2 x i32> %v, i32 %s, i32 %index
+ ret <2 x i32> %i
+}
+
+define <2 x i32> @zext_zext_use2(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @zext_zext_use2(
+; CHECK-NEXT: [[V:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[S:%.*]] = zext i8 [[Y:%.*]] to i32
+; CHECK-NEXT: call void @use(i32 [[S]])
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[I]]
+;
+ %v = zext <2 x i8> %x to <2 x i32>
+ %s = zext i8 %y to i32
+ call void @use(i32 %s)
+ %i = insertelement <2 x i32> %v, i32 %s, i32 %index
+ ret <2 x i32> %i
+}
+
+define <2 x i32> @zext_zext_use3(<2 x i8> %x, i8 %y, i32 %index) {
+; CHECK-LABEL: @zext_zext_use3(
+; CHECK-NEXT: [[V:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: call void @usevec(<2 x i32> [[V]])
+; CHECK-NEXT: [[S:%.*]] = zext i8 [[Y:%.*]] to i32
+; CHECK-NEXT: call void @use(i32 [[S]])
+; CHECK-NEXT: [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[I]]
+;
+ %v = zext <2 x i8> %x to <2 x i32>
+ call void @usevec(<2 x i32> %v)
+ %s = zext i8 %y to i32
+ call void @use(i32 %s)
+ %i = insertelement <2 x i32> %v, i32 %s, i32 %index
+ ret <2 x i32> %i
+}
More information about the llvm-commits
mailing list