[InstCombine] add tests for ashr exact; NFC
authorSanjay Patel <spatel@rotateright.com>
Fri, 7 Oct 2022 17:03:56 +0000 (13:03 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 7 Oct 2022 17:16:55 +0000 (13:16 -0400)
llvm/test/Transforms/InstCombine/ashr-lshr.ll

index 8708479..1ee5c9a 100644 (file)
@@ -582,3 +582,25 @@ define <3 x i43> @ashr_sub_nsw_splat_undef(<3 x i43> %x, <3 x i43> %y) {
   %shr = ashr <3 x i43> %sub, <i43 42, i43 undef, i43 42>
   ret <3 x i43> %shr
 }
+
+define i8 @ashr_known_pos_exact(i8 %x, i8 %y) {
+; CHECK-LABEL: @ashr_known_pos_exact(
+; CHECK-NEXT:    [[P:%.*]] = and i8 [[X:%.*]], 127
+; CHECK-NEXT:    [[R:%.*]] = lshr i8 [[P]], [[Y:%.*]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %p = and i8 %x, 127
+  %r = ashr exact i8 %p, %y
+  ret i8 %r
+}
+
+define <2 x i8> @ashr_known_pos_exact_vec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @ashr_known_pos_exact_vec(
+; CHECK-NEXT:    [[P:%.*]] = mul nsw <2 x i8> [[X:%.*]], [[X]]
+; CHECK-NEXT:    [[R:%.*]] = lshr <2 x i8> [[P]], [[Y:%.*]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %p = mul nsw <2 x i8> %x, %x
+  %r = ashr exact <2 x i8> %p, %y
+  ret <2 x i8> %r
+}