[llvm] a73973c - [InstCombine] add test for shift-trunc-shift with extra uses; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 6 08:29:30 PDT 2021


Author: Sanjay Patel
Date: 2021-09-06T11:13:38-04:00
New Revision: a73973c9d4616679569010d800f89be650dafcb7

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

LOG: [InstCombine] add test for shift-trunc-shift with extra uses; NFC

The transform doesn't check for extra uses, so we
have more instructions than we started with.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/shift-amount-reassociation-with-truncation-shl.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-with-truncation-shl.ll b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-with-truncation-shl.ll
index 223b2629cc63..4b762075fbdf 100644
--- a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-with-truncation-shl.ll
+++ b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-with-truncation-shl.ll
@@ -210,3 +210,21 @@ define i16 @t01(i32 %x) {
   %t2 = shl i16 %t1, ptrtoint (i16* @Y16 to i16)
   ret i16 %t2
 }
+
+define i16 @shl_tr_shl_constant_shift_amount_uses(i32 %x) {
+; CHECK-LABEL: @shl_tr_shl_constant_shift_amount_uses(
+; CHECK-NEXT:    [[SHL:%.*]] = shl i32 [[X:%.*]], 3
+; CHECK-NEXT:    call void @use32(i32 [[SHL]])
+; CHECK-NEXT:    [[TR:%.*]] = trunc i32 [[SHL]] to i16
+; CHECK-NEXT:    call void @use16(i16 [[TR]])
+; CHECK-NEXT:    [[X_TR:%.*]] = trunc i32 [[X]] to i16
+; CHECK-NEXT:    [[R:%.*]] = shl i16 [[X_TR]], 7
+; CHECK-NEXT:    ret i16 [[R]]
+;
+  %shl = shl i32 %x, 3
+  call void @use32(i32 %shl)
+  %tr = trunc i32 %shl to i16
+  call void @use16(i16 %tr)
+  %r = shl i16 %tr, 4
+  ret i16 %r
+}


        


More information about the llvm-commits mailing list