[llvm] 339d0c1 - [InstCombine] add test for shl demanded bits miscompile; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 10:54:21 PDT 2021


Author: Sanjay Patel
Date: 2021-05-14T13:54:13-04:00
New Revision: 339d0c1d26b638c54abe98aff81e4b00b3549023

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

LOG: [InstCombine] add test for shl demanded bits miscompile; NFC

PR50341

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/shl-demand.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/shl-demand.ll b/llvm/test/Transforms/InstCombine/shl-demand.ll
index f2e59a1c4fcc6..245c703319070 100644
--- a/llvm/test/Transforms/InstCombine/shl-demand.ll
+++ b/llvm/test/Transforms/InstCombine/shl-demand.ll
@@ -84,3 +84,17 @@ define i32 @set_shl_mask(i32 %x, i32 %y) {
   %r = and i32 %s, 65536
   ret i32 %r
 }
+
+; PR50341
+
+define i8 @must_drop_poison(i32 %x, i32 %y)  {
+; CHECK-LABEL: @must_drop_poison(
+; CHECK-NEXT:    [[S:%.*]] = shl nuw nsw i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[T:%.*]] = trunc i32 [[S]] to i8
+; CHECK-NEXT:    ret i8 [[T]]
+;
+  %a = and i32 %x, 255
+  %s = shl nuw nsw i32 %a, %y
+  %t = trunc i32 %s to i8
+  ret i8 %t
+}


        


More information about the llvm-commits mailing list