[llvm] d48a3b8 - [InstCombine] add tests for icmp (trunc X), C; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 12:51:52 PDT 2022


Author: Sanjay Patel
Date: 2022-06-30T15:51:39-04:00
New Revision: d48a3b866c3d8a7b329907c4adecf29d814ad79c

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

LOG: [InstCombine] add tests for icmp (trunc X), C; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/icmp-trunc.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/icmp-trunc.ll b/llvm/test/Transforms/InstCombine/icmp-trunc.ll
index 1218fdb70699..5b38b941497e 100644
--- a/llvm/test/Transforms/InstCombine/icmp-trunc.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-trunc.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+; RUN: opt < %s -passes=instcombine -S -data-layout="n8:16:32:64" | FileCheck %s --check-prefixes=CHECK,DL64
+; RUN: opt < %s -passes=instcombine -S -data-layout="n8"          | FileCheck %s --check-prefixes=CHECK,DL8
 
 declare void @use(i8)
 
@@ -310,3 +311,36 @@ define i1 @sgt_n1_use(i32 %x) {
   %r = icmp sgt i8 %t, -1
   ret i1 %r
 }
+
+define i1 @trunc_eq_i32_i8(i32 %x) {
+; CHECK-LABEL: @trunc_eq_i32_i8(
+; CHECK-NEXT:    [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[T]], 42
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %t = trunc i32 %x to i8
+  %r = icmp eq i8 %t, 42
+  ret i1 %r
+}
+
+define <2 x i1> @trunc_eq_v2i32_v2i8(<2 x i32> %x) {
+; CHECK-LABEL: @trunc_eq_v2i32_v2i8(
+; CHECK-NEXT:    [[T:%.*]] = trunc <2 x i32> [[X:%.*]] to <2 x i8>
+; CHECK-NEXT:    [[R:%.*]] = icmp eq <2 x i8> [[T]], <i8 42, i8 42>
+; CHECK-NEXT:    ret <2 x i1> [[R]]
+;
+  %t = trunc <2 x i32> %x to <2 x i8>
+  %r = icmp eq <2 x i8> %t, <i8 42, i8 42>
+  ret <2 x i1> %r
+}
+
+define i1 @trunc_ne_i64_i10(i64 %x) {
+; CHECK-LABEL: @trunc_ne_i64_i10(
+; CHECK-NEXT:    [[T:%.*]] = trunc i64 [[X:%.*]] to i10
+; CHECK-NEXT:    [[R:%.*]] = icmp eq i10 [[T]], 42
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %t = trunc i64 %x to i10
+  %r = icmp eq i10 %t, 42
+  ret i1 %r
+}


        


More information about the llvm-commits mailing list