[llvm] 61196f8 - [InstSimplify] add tests for computeKnownBits of shift-with-bitcast op; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 09:45:45 PDT 2021


Author: Sanjay Patel
Date: 2021-06-17T12:39:16-04:00
New Revision: 61196f855c395b14bffd7c9b1ba29194577e67f6

URL: https://github.com/llvm/llvm-project/commit/61196f855c395b14bffd7c9b1ba29194577e67f6
DIFF: https://github.com/llvm/llvm-project/commit/61196f855c395b14bffd7c9b1ba29194577e67f6.diff

LOG: [InstSimplify] add tests for computeKnownBits of shift-with-bitcast op; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/shift-knownbits.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/shift-knownbits.ll b/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
index e7302b66ea8a..c8c5a6e99fe5 100644
--- a/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
+++ b/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instsimplify -S | FileCheck %s
+; RUN: opt < %s -instsimplify -S -data-layout="E" | FileCheck %s
 
 ; If any bits of the shift amount are known to make it exceed or equal
 ; the number of bits in the type, the shift causes undefined behavior.
@@ -223,3 +223,114 @@ define i8 @lshr_cttz_zero_is_undef_vec(<2 x i8> %x) {
   ret i8 %ex
 }
 
+define i24 @bitcast_noshift_scalar(<3 x i8> %v1, i24 %v2) {
+; CHECK-LABEL: @bitcast_noshift_scalar(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <3 x i8> [[V1:%.*]], <3 x i8> <i8 0, i8 poison, i8 poison>, <3 x i32> <i32 3, i32 1, i32 3>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x i8> [[S]] to i24
+; CHECK-NEXT:    [[R:%.*]] = shl i24 [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret i24 [[R]]
+;
+  %c = insertelement <3 x i8> poison, i8 0, i64 0
+  %s = shufflevector <3 x i8> %v1, <3 x i8> %c, <3 x i32> <i32 3, i32 1, i32 3>
+  %b = bitcast <3 x i8> %s to i24
+  %r = shl i24 %v2, %b
+  ret i24 %r
+}
+
+define i24 @bitcast_noshift_scalar_bigend(<3 x i8> %v1, i24 %v2) {
+; CHECK-LABEL: @bitcast_noshift_scalar_bigend(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <3 x i8> [[V1:%.*]], <3 x i8> <i8 0, i8 poison, i8 poison>, <3 x i32> <i32 0, i32 1, i32 3>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x i8> [[S]] to i24
+; CHECK-NEXT:    [[R:%.*]] = shl i24 [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret i24 [[R]]
+;
+  %c = insertelement <3 x i8> poison, i8 0, i64 0
+  %s = shufflevector <3 x i8> %v1, <3 x i8> %c, <3 x i32> <i32 0, i32 1, i32 3>
+  %b = bitcast <3 x i8> %s to i24
+  %r = shl i24 %v2, %b
+  ret i24 %r
+}
+
+define i24 @bitcast_noshift_scalar_littleend(<3 x i8> %v1, i24 %v2) {
+; CHECK-LABEL: @bitcast_noshift_scalar_littleend(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <3 x i8> [[V1:%.*]], <3 x i8> <i8 0, i8 poison, i8 poison>, <3 x i32> <i32 3, i32 1, i32 2>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <3 x i8> [[S]] to i24
+; CHECK-NEXT:    [[R:%.*]] = shl i24 [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret i24 [[R]]
+;
+  %c = insertelement <3 x i8> poison, i8 0, i64 0
+  %s = shufflevector <3 x i8> %v1, <3 x i8> %c, <3 x i32> <i32 3, i32 1, i32 2>
+  %b = bitcast <3 x i8> %s to i24
+  %r = shl i24 %v2, %b
+  ret i24 %r
+}
+
+define <3 x i24> @bitcast_overshift_vector(<9 x i8> %v1, <3 x i24> %v2) {
+; CHECK-LABEL: @bitcast_overshift_vector(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <9 x i8> [[V1:%.*]], <9 x i8> <i8 24, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 9, i32 7, i32 8>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <9 x i8> [[S]] to <3 x i24>
+; CHECK-NEXT:    [[R:%.*]] = shl <3 x i24> [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret <3 x i24> [[R]]
+;
+  %c = insertelement <9 x i8> poison, i8 24, i64 0
+  %s = shufflevector <9 x i8> %v1, <9 x i8> %c, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 9, i32 7, i32 8>
+  %b = bitcast <9 x i8> %s to <3 x i24>
+  %r = shl <3 x i24> %v2, %b
+  ret <3 x i24> %r
+}
+
+define <3 x i24> @bitcast_overshift_vector_bigend(<9 x i8> %v1, <3 x i24> %v2) {
+; CHECK-LABEL: @bitcast_overshift_vector_bigend(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <9 x i8> [[V1:%.*]], <9 x i8> <i8 23, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 9, i32 7, i32 8>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <9 x i8> [[S]] to <3 x i24>
+; CHECK-NEXT:    [[R:%.*]] = shl <3 x i24> [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret <3 x i24> [[R]]
+;
+  %c = insertelement <9 x i8> poison, i8 23, i64 0
+  %s = shufflevector <9 x i8> %v1, <9 x i8> %c, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 9, i32 7, i32 8>
+  %b = bitcast <9 x i8> %s to <3 x i24>
+  %r = shl <3 x i24> %v2, %b
+  ret <3 x i24> %r
+}
+
+define <3 x i24> @bitcast_overshift_vector_littleend(<9 x i8> %v1, <3 x i24> %v2) {
+; CHECK-LABEL: @bitcast_overshift_vector_littleend(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <9 x i8> [[V1:%.*]], <9 x i8> <i8 23, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <9 x i32> <i32 0, i32 1, i32 9, i32 3, i32 4, i32 9, i32 6, i32 7, i32 9>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <9 x i8> [[S]] to <3 x i24>
+; CHECK-NEXT:    [[R:%.*]] = shl <3 x i24> [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret <3 x i24> [[R]]
+;
+  %c = insertelement <9 x i8> poison, i8 23, i64 0
+  %s = shufflevector <9 x i8> %v1, <9 x i8> %c, <9 x i32> <i32 0, i32 1, i32 9, i32 3, i32 4, i32 9, i32 6, i32 7, i32 9>
+  %b = bitcast <9 x i8> %s to <3 x i24>
+  %r = shl <3 x i24> %v2, %b
+  ret <3 x i24> %r
+}
+
+define <3 x i24> @bitcast_partial_overshift_vector(<9 x i8> %v1, <3 x i24> %v2) {
+; CHECK-LABEL: @bitcast_partial_overshift_vector(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <9 x i8> [[V1:%.*]], <9 x i8> <i8 24, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 6, i32 7, i32 8>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <9 x i8> [[S]] to <3 x i24>
+; CHECK-NEXT:    [[R:%.*]] = shl <3 x i24> [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret <3 x i24> [[R]]
+;
+  %c = insertelement <9 x i8> poison, i8 24, i64 0
+  %s = shufflevector <9 x i8> %v1, <9 x i8> %c, <9 x i32> <i32 9, i32 1, i32 2, i32 9, i32 4, i32 5, i32 6, i32 7, i32 8>
+  %b = bitcast <9 x i8> %s to <3 x i24>
+  %r = shl <3 x i24> %v2, %b
+  ret <3 x i24> %r
+}
+
+define <1 x i64> @bitcast_noshift_vector_wrong_type(<2 x float> %v1, <1 x i64> %v2) {
+; CHECK-LABEL: @bitcast_noshift_vector_wrong_type(
+; CHECK-NEXT:    [[S:%.*]] = shufflevector <2 x float> [[V1:%.*]], <2 x float> <float 0.000000e+00, float poison>, <2 x i32> <i32 2, i32 1>
+; CHECK-NEXT:    [[B:%.*]] = bitcast <2 x float> [[S]] to <1 x i64>
+; CHECK-NEXT:    [[R:%.*]] = shl <1 x i64> [[V2:%.*]], [[B]]
+; CHECK-NEXT:    ret <1 x i64> [[R]]
+;
+  %c = insertelement <2 x float> poison, float 0.0, i64 0
+  %s = shufflevector <2 x float> %v1, <2 x float> %c, <2 x i32> <i32 2, i32 1>
+  %b = bitcast <2 x float> %s to <1 x i64>
+  %r = shl <1 x i64> %v2, %b
+  ret <1 x i64> %r
+}


        


More information about the llvm-commits mailing list