[llvm] bd2c6e5 - [InstCombine] add tests for extractelt of bitcasted scalar; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 4 11:32:10 PDT 2021
Author: Sanjay Patel
Date: 2021-10-04T14:30:18-04:00
New Revision: bd2c6e52bb9c96841adfa5f9cd794e20205babfd
URL: https://github.com/llvm/llvm-project/commit/bd2c6e52bb9c96841adfa5f9cd794e20205babfd
DIFF: https://github.com/llvm/llvm-project/commit/bd2c6e52bb9c96841adfa5f9cd794e20205babfd.diff
LOG: [InstCombine] add tests for extractelt of bitcasted scalar; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/extractelement.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/extractelement.ll b/llvm/test/Transforms/InstCombine/extractelement.ll
index 5f5f0a94ce5fa..d6327c13db4f1 100644
--- a/llvm/test/Transforms/InstCombine/extractelement.ll
+++ b/llvm/test/Transforms/InstCombine/extractelement.ll
@@ -1,6 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S -data-layout="e" | FileCheck %s --check-prefixes=ANY,LE
-; RUN: opt < %s -instcombine -S -data-layout="E" | FileCheck %s --check-prefixes=ANY,BE
+; RUN: opt < %s -instcombine -S -data-layout="e-n64" | FileCheck %s --check-prefixes=ANY,LE
+; RUN: opt < %s -instcombine -S -data-layout="E-n64" | FileCheck %s --check-prefixes=ANY,BE
define i32 @extractelement_out_of_range(<2 x i32> %x) {
; ANY-LABEL: @extractelement_out_of_range(
@@ -329,3 +329,93 @@ define <4 x double> @invalid_extractelement(<2 x double> %a, <4 x double> %b, do
%r = insertelement <4 x double> %t4, double %e1, i64 0
ret <4 x double> %r
}
+
+define i8 @bitcast_scalar_supported_type_index0(i32 %x) {
+; ANY-LABEL: @bitcast_scalar_supported_type_index0(
+; ANY-NEXT: [[V:%.*]] = bitcast i32 [[X:%.*]] to <4 x i8>
+; ANY-NEXT: [[R:%.*]] = extractelement <4 x i8> [[V]], i8 0
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast i32 %x to <4 x i8>
+ %r = extractelement <4 x i8> %v, i8 0
+ ret i8 %r
+}
+
+define i8 @bitcast_scalar_supported_type_index2(i32 %x) {
+; ANY-LABEL: @bitcast_scalar_supported_type_index2(
+; ANY-NEXT: [[V:%.*]] = bitcast i32 [[X:%.*]] to <4 x i8>
+; ANY-NEXT: [[R:%.*]] = extractelement <4 x i8> [[V]], i64 2
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast i32 %x to <4 x i8>
+ %r = extractelement <4 x i8> %v, i64 2
+ ret i8 %r
+}
+
+define i4 @bitcast_scalar_legal_type_index3(i64 %x) {
+; ANY-LABEL: @bitcast_scalar_legal_type_index3(
+; ANY-NEXT: [[V:%.*]] = bitcast i64 [[X:%.*]] to <16 x i4>
+; ANY-NEXT: [[R:%.*]] = extractelement <16 x i4> [[V]], i64 3
+; ANY-NEXT: ret i4 [[R]]
+;
+ %v = bitcast i64 %x to <16 x i4>
+ %r = extractelement <16 x i4> %v, i64 3
+ ret i4 %r
+}
+
+define i8 @bitcast_scalar_illegal_type_index1(i128 %x) {
+; ANY-LABEL: @bitcast_scalar_illegal_type_index1(
+; ANY-NEXT: [[V:%.*]] = bitcast i128 [[X:%.*]] to <16 x i8>
+; ANY-NEXT: [[R:%.*]] = extractelement <16 x i8> [[V]], i64 1
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast i128 %x to <16 x i8>
+ %r = extractelement <16 x i8> %v, i64 1
+ ret i8 %r
+}
+
+define i8 @bitcast_fp_index0(float %x) {
+; ANY-LABEL: @bitcast_fp_index0(
+; ANY-NEXT: [[V:%.*]] = bitcast float [[X:%.*]] to <4 x i8>
+; ANY-NEXT: [[R:%.*]] = extractelement <4 x i8> [[V]], i8 0
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast float %x to <4 x i8>
+ %r = extractelement <4 x i8> %v, i8 0
+ ret i8 %r
+}
+
+define half @bitcast_fpvec_index0(i32 %x) {
+; ANY-LABEL: @bitcast_fpvec_index0(
+; ANY-NEXT: [[V:%.*]] = bitcast i32 [[X:%.*]] to <2 x half>
+; ANY-NEXT: [[R:%.*]] = extractelement <2 x half> [[V]], i8 0
+; ANY-NEXT: ret half [[R]]
+;
+ %v = bitcast i32 %x to <2 x half>
+ %r = extractelement <2 x half> %v, i8 0
+ ret half %r
+}
+
+define i8 @bitcast_scalar_index_variable(i32 %x, i64 %y) {
+; ANY-LABEL: @bitcast_scalar_index_variable(
+; ANY-NEXT: [[V:%.*]] = bitcast i32 [[X:%.*]] to <4 x i8>
+; ANY-NEXT: [[R:%.*]] = extractelement <4 x i8> [[V]], i64 [[Y:%.*]]
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast i32 %x to <4 x i8>
+ %r = extractelement <4 x i8> %v, i64 %y
+ ret i8 %r
+}
+
+define i8 @bitcast_scalar_index0_use(i64 %x) {
+; ANY-LABEL: @bitcast_scalar_index0_use(
+; ANY-NEXT: [[V:%.*]] = bitcast i64 [[X:%.*]] to <8 x i8>
+; ANY-NEXT: call void @use(<8 x i8> [[V]])
+; ANY-NEXT: [[R:%.*]] = extractelement <8 x i8> [[V]], i64 0
+; ANY-NEXT: ret i8 [[R]]
+;
+ %v = bitcast i64 %x to <8 x i8>
+ call void @use(<8 x i8> %v)
+ %r = extractelement <8 x i8> %v, i64 0
+ ret i8 %r
+}
More information about the llvm-commits
mailing list