aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2024-06-08 15:16:37 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2024-06-08 16:46:45 -0500
commitc2d68c42a44853dccf8df736ed9be85a8be3ef70 (patch)
tree5d244a0d0efdd7e7526820a1fd32b9685c2f119d
parentfebfbff6cde47b1632424a4c5192a4aae79892c5 (diff)
downloadllvm-c2d68c42a44853dccf8df736ed9be85a8be3ef70.zip
llvm-c2d68c42a44853dccf8df736ed9be85a8be3ef70.tar.gz
llvm-c2d68c42a44853dccf8df736ed9be85a8be3ef70.tar.bz2
[InstCombine] Add tests for propagating flags when folding consecutative shifts; NFC
-rw-r--r--llvm/test/Transforms/InstCombine/shift.ll80
1 files changed, 80 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll
index 8da52e0..8726747 100644
--- a/llvm/test/Transforms/InstCombine/shift.ll
+++ b/llvm/test/Transforms/InstCombine/shift.ll
@@ -2240,4 +2240,84 @@ define i129 @shift_zext_not_nneg(i8 %arg) {
ret i129 %shl
}
+define i8 @src_shl_nsw(i8 %x) {
+; CHECK-LABEL: @src_shl_nsw(
+; CHECK-NEXT: [[R:%.*]] = shl i8 32, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = shl nsw i8 1, %x
+ %r = shl nsw i8 %sh, 5
+ ret i8 %r
+}
+
+define i8 @src_shl_nsw_fail(i8 %x) {
+; CHECK-LABEL: @src_shl_nsw_fail(
+; CHECK-NEXT: [[R:%.*]] = shl i8 32, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = shl nsw i8 1, %x
+ %r = shl i8 %sh, 5
+ ret i8 %r
+}
+
+define i8 @src_shl_nuw(i8 %x) {
+; CHECK-LABEL: @src_shl_nuw(
+; CHECK-NEXT: [[R:%.*]] = shl i8 12, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = shl nuw i8 3, %x
+ %r = shl nuw i8 %sh, 2
+ ret i8 %r
+}
+
+define i8 @src_shl_nuw_fail(i8 %x) {
+; CHECK-LABEL: @src_shl_nuw_fail(
+; CHECK-NEXT: [[R:%.*]] = shl i8 12, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = shl i8 3, %x
+ %r = shl nuw i8 %sh, 2
+ ret i8 %r
+}
+
+define i8 @src_lshr_exact(i8 %x) {
+; CHECK-LABEL: @src_lshr_exact(
+; CHECK-NEXT: [[R:%.*]] = lshr i8 48, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = lshr exact i8 96, %x
+ %r = lshr exact i8 %sh, 1
+ ret i8 %r
+}
+
+define i8 @src_lshr_exact_fail(i8 %x) {
+; CHECK-LABEL: @src_lshr_exact_fail(
+; CHECK-NEXT: [[R:%.*]] = lshr i8 48, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = lshr exact i8 96, %x
+ %r = lshr i8 %sh, 1
+ ret i8 %r
+}
+
+define i8 @src_ashr_exact(i8 %x) {
+; CHECK-LABEL: @src_ashr_exact(
+; CHECK-NEXT: [[R:%.*]] = ashr i8 -8, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = ashr exact i8 -32, %x
+ %r = ashr exact i8 %sh, 2
+ ret i8 %r
+}
+
+define i8 @src_ashr_exact_fail(i8 %x) {
+; CHECK-LABEL: @src_ashr_exact_fail(
+; CHECK-NEXT: [[R:%.*]] = ashr i8 -8, [[X:%.*]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %sh = ashr i8 -32, %x
+ %r = ashr exact i8 %sh, 2
+ ret i8 %r
+}
+
declare i16 @llvm.umax.i16(i16, i16)