xref: /llvm-project/llvm/test/Analysis/ValueTracking/knownbits-shift.ll (revision d81db0e5f5b1404ff4813af3050d671528ad45cc)
1f19d9e16SNoah Goldstein; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2f19d9e16SNoah Goldstein; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3f19d9e16SNoah Goldstein
4f19d9e16SNoah Goldsteindefine i8 @simplify_lshr_with_exact(i8 %x) {
5f19d9e16SNoah Goldstein; CHECK-LABEL: @simplify_lshr_with_exact(
6*d81db0e5SNoah Goldstein; CHECK-NEXT:    ret i8 2
7f19d9e16SNoah Goldstein;
8f19d9e16SNoah Goldstein  %shr = lshr exact i8 6, %x
9f19d9e16SNoah Goldstein  %r = and i8 %shr, 2
10f19d9e16SNoah Goldstein  ret i8 %r
11f19d9e16SNoah Goldstein}
12f19d9e16SNoah Goldstein
13f19d9e16SNoah Goldsteindefine i8 @simplify_ashr_with_exact(i8 %x) {
14f19d9e16SNoah Goldstein; CHECK-LABEL: @simplify_ashr_with_exact(
15*d81db0e5SNoah Goldstein; CHECK-NEXT:    ret i8 2
16f19d9e16SNoah Goldstein;
17f19d9e16SNoah Goldstein  %shr = ashr exact i8 -122, %x
18f19d9e16SNoah Goldstein  %r = and i8 %shr, 2
19f19d9e16SNoah Goldstein  ret i8 %r
20f19d9e16SNoah Goldstein}
21