[llvm] 7618355 - [InstCombine] add tests for smear-a-set-bit; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 08:42:38 PDT 2021
Author: Sanjay Patel
Date: 2021-09-07T11:42:33-04:00
New Revision: 761835521cdb0fe42bb3d550e7fd65aede1ac56a
URL: https://github.com/llvm/llvm-project/commit/761835521cdb0fe42bb3d550e7fd65aede1ac56a
DIFF: https://github.com/llvm/llvm-project/commit/761835521cdb0fe42bb3d550e7fd65aede1ac56a.diff
LOG: [InstCombine] add tests for smear-a-set-bit; NFC
Possible follow-ups from patterns discussed in D109155.
Added:
Modified:
llvm/test/Transforms/InstCombine/sext.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/sext.ll b/llvm/test/Transforms/InstCombine/sext.ll
index 1fc645cc9289..eec2f9be2f79 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -6,6 +6,8 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
declare i32 @llvm.ctpop.i32(i32)
declare i32 @llvm.ctlz.i32(i32, i1)
declare i32 @llvm.cttz.i32(i32, i1)
+declare void @use(i8)
+declare void @use_vec(<2 x i5>)
define i64 @test1(i32 %x) {
; CHECK-LABEL: @test1(
@@ -318,3 +320,72 @@ define i10 @test19(i10 %i) {
%d = sext i3 %c to i10
ret i10 %d
}
+
+define i32 @smear_set_bit(i32 %x) {
+; CHECK-LABEL: @smear_set_bit(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[A:%.*]] = ashr i8 [[T]], 7
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[A]] to i32
+; CHECK-NEXT: ret i32 [[S]]
+;
+ %t = trunc i32 %x to i8
+ %a = ashr i8 %t, 7
+ %s = sext i8 %a to i32
+ ret i32 %s
+}
+
+define <2 x i32> @smear_set_bit_vec_use1(<2 x i32> %x) {
+; CHECK-LABEL: @smear_set_bit_vec_use1(
+; CHECK-NEXT: [[T:%.*]] = trunc <2 x i32> [[X:%.*]] to <2 x i5>
+; CHECK-NEXT: call void @use_vec(<2 x i5> [[T]])
+; CHECK-NEXT: [[A:%.*]] = ashr <2 x i5> [[T]], <i5 4, i5 4>
+; CHECK-NEXT: [[S:%.*]] = sext <2 x i5> [[A]] to <2 x i32>
+; CHECK-NEXT: ret <2 x i32> [[S]]
+;
+ %t = trunc <2 x i32> %x to <2 x i5>
+ call void @use_vec(<2 x i5> %t)
+ %a = ashr <2 x i5> %t, <i5 4, i5 4>
+ %s = sext <2 x i5> %a to <2 x i32>
+ ret <2 x i32> %s
+}
+
+define i32 @smear_set_bit_use2(i32 %x) {
+; CHECK-LABEL: @smear_set_bit_use2(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[A:%.*]] = ashr i8 [[T]], 7
+; CHECK-NEXT: call void @use(i8 [[A]])
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[A]] to i32
+; CHECK-NEXT: ret i32 [[S]]
+;
+ %t = trunc i32 %x to i8
+ %a = ashr i8 %t, 7
+ call void @use(i8 %a)
+ %s = sext i8 %a to i32
+ ret i32 %s
+}
+
+define i32 @smear_set_bit_wrong_shift_amount(i32 %x) {
+; CHECK-LABEL: @smear_set_bit_wrong_shift_amount(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[A:%.*]] = ashr i8 [[T]], 6
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[A]] to i32
+; CHECK-NEXT: ret i32 [[S]]
+;
+ %t = trunc i32 %x to i8
+ %a = ashr i8 %t, 6
+ %s = sext i8 %a to i32
+ ret i32 %s
+}
+
+define i16 @smear_set_bit_
diff erent_dest_type(i32 %x) {
+; CHECK-LABEL: @smear_set_bit_
diff erent_dest_type(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[A:%.*]] = ashr i8 [[T]], 7
+; CHECK-NEXT: [[S:%.*]] = sext i8 [[A]] to i16
+; CHECK-NEXT: ret i16 [[S]]
+;
+ %t = trunc i32 %x to i8
+ %a = ashr i8 %t, 7
+ %s = sext i8 %a to i16
+ ret i16 %s
+}
More information about the llvm-commits
mailing list