[llvm] 88a9c18 - [InstCombine] add test for shl + demanded bits; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 3 07:39:26 PDT 2021


Author: Sanjay Patel
Date: 2021-10-03T10:35:59-04:00
New Revision: 88a9c1827e8dfd74aa2b2ba4f58ddf557b253c4e

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

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

This is a reduction of a test that would infinite loop with D110170.

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 11c2de8e58d75..eca81cebe5cd4 100644
--- a/llvm/test/Transforms/InstCombine/shl-demand.ll
+++ b/llvm/test/Transforms/InstCombine/shl-demand.ll
@@ -98,3 +98,20 @@ define i8 @must_drop_poison(i32 %x, i32 %y)  {
   %t = trunc i32 %s to i8
   ret i8 %t
 }
+
+; This would infinite loop with D110170 / bb9333c3504a
+
+define i32 @f_t15_t01_t09(i40 %t2) {
+; CHECK-LABEL: @f_t15_t01_t09(
+; CHECK-NEXT:    [[SH_DIFF:%.*]] = ashr i40 [[T2:%.*]], 15
+; CHECK-NEXT:    [[TR_SH_DIFF:%.*]] = trunc i40 [[SH_DIFF]] to i32
+; CHECK-NEXT:    [[SHL1:%.*]] = and i32 [[TR_SH_DIFF]], -65536
+; CHECK-NEXT:    ret i32 [[SHL1]]
+;
+  %downscale = ashr i40 %t2, 31
+  %resize = trunc i40 %downscale to i32
+  %shl1 = shl i32 %resize, 16
+  %resize1 = ashr i32 %shl1, 16
+  %r = shl i32 %resize1, 31
+  ret i32 %shl1
+}


        


More information about the llvm-commits mailing list