[llvm] f19d9e1 - [KnownBits] Add test for computing more information for `lshr`/`ashr` with `exact` flag; NFC

Noah Goldstein via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 13:51:31 PDT 2024


Author: Noah Goldstein
Date: 2024-03-11T15:51:06-05:00
New Revision: f19d9e1617292a95b665171574630b8674d3ae1e

URL: https://github.com/llvm/llvm-project/commit/f19d9e1617292a95b665171574630b8674d3ae1e
DIFF: https://github.com/llvm/llvm-project/commit/f19d9e1617292a95b665171574630b8674d3ae1e.diff

LOG: [KnownBits] Add test for computing more information for `lshr`/`ashr` with `exact` flag; NFC

Added: 
    llvm/test/Analysis/ValueTracking/knownbits-shift.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ValueTracking/knownbits-shift.ll b/llvm/test/Analysis/ValueTracking/knownbits-shift.ll
new file mode 100644
index 00000000000000..3235f69b5221a1
--- /dev/null
+++ b/llvm/test/Analysis/ValueTracking/knownbits-shift.ll
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=instcombine -S < %s | FileCheck %s
+
+define i8 @simplify_lshr_with_exact(i8 %x) {
+; CHECK-LABEL: @simplify_lshr_with_exact(
+; CHECK-NEXT:    [[SHR:%.*]] = lshr exact i8 6, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = and i8 [[SHR]], 2
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %shr = lshr exact i8 6, %x
+  %r = and i8 %shr, 2
+  ret i8 %r
+}
+
+define i8 @simplify_ashr_with_exact(i8 %x) {
+; CHECK-LABEL: @simplify_ashr_with_exact(
+; CHECK-NEXT:    [[SHR:%.*]] = ashr exact i8 -122, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = and i8 [[SHR]], 2
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %shr = ashr exact i8 -122, %x
+  %r = and i8 %shr, 2
+  ret i8 %r
+}


        


More information about the llvm-commits mailing list