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