From a81fdef780153f7eefbc324a3b669f59ef1cf760 Mon Sep 17 00:00:00 2001 From: Nicola Zaghen Date: Tue, 21 Aug 2018 15:27:32 +0000 Subject: [PATCH] [InstCombine] Add new tests for icmp ugt/ult (add nuw X, C2), C Differential Revision: https://reviews.llvm.org/D51040 llvm-svn: 340284 --- test/Transforms/InstCombine/icmp-add.ll | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/Transforms/InstCombine/icmp-add.ll b/test/Transforms/InstCombine/icmp-add.ll index ec2fd13315e..49517e580ef 100644 --- a/test/Transforms/InstCombine/icmp-add.ll +++ b/test/Transforms/InstCombine/icmp-add.ll @@ -281,3 +281,46 @@ define i1 @slt_zero_add_nuw_signbit(i8 %x) { ret i1 %z } +define i1 @reduce_add_ult(i32 %in) { +; CHECK-LABEL: @reduce_add_ult( +; CHECK-NEXT: [[A6:%.*]] = add nuw i32 [[IN:%.*]], 3 +; CHECK-NEXT: [[A18:%.*]] = icmp ult i32 [[A6]], 12 +; CHECK-NEXT: ret i1 [[A18]] +; + %a6 = add nuw i32 %in, 3 + %a18 = icmp ult i32 %a6, 12 + ret i1 %a18 +} + +define i1 @reduce_add_ugt(i32 %in) { +; CHECK-LABEL: @reduce_add_ugt( +; CHECK-NEXT: [[A6:%.*]] = add nuw i32 [[IN:%.*]], 3 +; CHECK-NEXT: [[A18:%.*]] = icmp ugt i32 [[A6]], 12 +; CHECK-NEXT: ret i1 [[A18]] +; + %a6 = add nuw i32 %in, 3 + %a18 = icmp ugt i32 %a6, 12 + ret i1 %a18 +} + +define i1 @reduce_add_ule(i32 %in) { +; CHECK-LABEL: @reduce_add_ule( +; CHECK-NEXT: [[A6:%.*]] = add nuw i32 [[IN:%.*]], 3 +; CHECK-NEXT: [[A18:%.*]] = icmp ult i32 [[A6]], 13 +; CHECK-NEXT: ret i1 [[A18]] +; + %a6 = add nuw i32 %in, 3 + %a18 = icmp ule i32 %a6, 12 + ret i1 %a18 +} + +define i1 @reduce_add_uge(i32 %in) { +; CHECK-LABEL: @reduce_add_uge( +; CHECK-NEXT: [[A6:%.*]] = add nuw i32 [[IN:%.*]], 3 +; CHECK-NEXT: [[A18:%.*]] = icmp ugt i32 [[A6]], 11 +; CHECK-NEXT: ret i1 [[A18]] +; + %a6 = add nuw i32 %in, 3 + %a18 = icmp uge i32 %a6, 12 + ret i1 %a18 +}