[llvm] 04697aa - [InstCombine] Add test for displaced shift fold with or disjoint (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 06:00:47 PST 2023


Author: Nikita Popov
Date: 2023-12-07T15:00:40+01:00
New Revision: 04697aa18af83d9826b2f5949aa1b76c9f723da7

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

LOG: [InstCombine] Add test for displaced shift fold with or disjoint (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll b/llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll
index c86dfde6ddece..07ed8f2908896 100644
--- a/llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll
+++ b/llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll
@@ -328,3 +328,35 @@ define <2 x i8> @shl_or_non_splat_out_of_range(<2 x i8> %x) {
   %binop = or <2 x i8> %shift, %shift2
   ret <2 x i8> %binop
 }
+
+define i8 @shl_or_with_or_disjoint_instead_of_add(i8 %x) {
+; CHECK-LABEL: define i8 @shl_or_with_or_disjoint_instead_of_add
+; CHECK-SAME: (i8 [[X:%.*]]) {
+; CHECK-NEXT:    [[SHIFT:%.*]] = shl i8 16, [[X]]
+; CHECK-NEXT:    [[ADD:%.*]] = or disjoint i8 [[X]], 1
+; CHECK-NEXT:    [[SHIFT2:%.*]] = shl i8 3, [[ADD]]
+; CHECK-NEXT:    [[BINOP:%.*]] = or i8 [[SHIFT]], [[SHIFT2]]
+; CHECK-NEXT:    ret i8 [[BINOP]]
+;
+  %shift = shl i8 16, %x
+  %add = or disjoint i8 %x, 1
+  %shift2 = shl i8 3, %add
+  %binop = or i8 %shift, %shift2
+  ret i8 %binop
+}
+
+define i8 @shl_or_with_or_instead_of_add(i8 %x) {
+; CHECK-LABEL: define i8 @shl_or_with_or_instead_of_add
+; CHECK-SAME: (i8 [[X:%.*]]) {
+; CHECK-NEXT:    [[SHIFT:%.*]] = shl i8 16, [[X]]
+; CHECK-NEXT:    [[ADD:%.*]] = or i8 [[X]], 1
+; CHECK-NEXT:    [[SHIFT2:%.*]] = shl i8 3, [[ADD]]
+; CHECK-NEXT:    [[BINOP:%.*]] = or i8 [[SHIFT]], [[SHIFT2]]
+; CHECK-NEXT:    ret i8 [[BINOP]]
+;
+  %shift = shl i8 16, %x
+  %add = or i8 %x, 1
+  %shift2 = shl i8 3, %add
+  %binop = or i8 %shift, %shift2
+  ret i8 %binop
+}


        


More information about the llvm-commits mailing list