From 32dd914f7182875730eb3453f39dcc584b7219b2 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 5 Jul 2021 09:13:38 -0400 Subject: [PATCH] [InstCombine][tests] add tests for signed icmp with constant and offset; NFC --- llvm/test/Transforms/InstCombine/icmp-add.ll | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/icmp-add.ll b/llvm/test/Transforms/InstCombine/icmp-add.ll index 8ad14004076f..1f00dc6e2992 100644 --- a/llvm/test/Transforms/InstCombine/icmp-add.ll +++ b/llvm/test/Transforms/InstCombine/icmp-add.ll @@ -839,3 +839,95 @@ define i1 @ult_wrong_offset(i8 %a) { %ov = icmp ult i8 %t, 123 ret i1 %ov } + +define i1 @sgt_offset(i8 %a) { +; CHECK-LABEL: @sgt_offset( +; CHECK-NEXT: [[T:%.*]] = add i8 [[A:%.*]], -6 +; CHECK-NEXT: [[OV:%.*]] = icmp sgt i8 [[T]], -7 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i8 %a, -6 + %ov = icmp sgt i8 %t, -7 + ret i1 %ov +} + +define i1 @sgt_offset_use(i32 %a) { +; CHECK-LABEL: @sgt_offset_use( +; CHECK-NEXT: [[T:%.*]] = add i32 [[A:%.*]], 42 +; CHECK-NEXT: call void @use(i32 [[T]]) +; CHECK-NEXT: [[OV:%.*]] = icmp sgt i32 [[T]], 41 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i32 %a, 42 + call void @use(i32 %t) + %ov = icmp sgt i32 %t, 41 + ret i1 %ov +} + +define <2 x i1> @sgt_offset_splat(<2 x i5> %a) { +; CHECK-LABEL: @sgt_offset_splat( +; CHECK-NEXT: [[T:%.*]] = add <2 x i5> [[A:%.*]], +; CHECK-NEXT: [[OV:%.*]] = icmp sgt <2 x i5> [[T]], +; CHECK-NEXT: ret <2 x i1> [[OV]] +; + %t = add <2 x i5> %a, + %ov = icmp sgt <2 x i5> %t, + ret <2 x i1> %ov +} + +define i1 @sgt_wrong_offset(i8 %a) { +; CHECK-LABEL: @sgt_wrong_offset( +; CHECK-NEXT: [[T:%.*]] = add i8 [[A:%.*]], -7 +; CHECK-NEXT: [[OV:%.*]] = icmp sgt i8 [[T]], -7 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i8 %a, -7 + %ov = icmp sgt i8 %t, -7 + ret i1 %ov +} + +define i1 @slt_offset(i8 %a) { +; CHECK-LABEL: @slt_offset( +; CHECK-NEXT: [[T:%.*]] = add i8 [[A:%.*]], -6 +; CHECK-NEXT: [[OV:%.*]] = icmp slt i8 [[T]], -6 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i8 %a, -6 + %ov = icmp slt i8 %t, -6 + ret i1 %ov +} + +define i1 @slt_offset_use(i32 %a) { +; CHECK-LABEL: @slt_offset_use( +; CHECK-NEXT: [[T:%.*]] = add i32 [[A:%.*]], 42 +; CHECK-NEXT: call void @use(i32 [[T]]) +; CHECK-NEXT: [[OV:%.*]] = icmp slt i32 [[T]], 42 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i32 %a, 42 + call void @use(i32 %t) + %ov = icmp slt i32 %t, 42 + ret i1 %ov +} + +define <2 x i1> @slt_offset_splat(<2 x i5> %a) { +; CHECK-LABEL: @slt_offset_splat( +; CHECK-NEXT: [[T:%.*]] = add <2 x i5> [[A:%.*]], +; CHECK-NEXT: [[OV:%.*]] = icmp slt <2 x i5> [[T]], +; CHECK-NEXT: ret <2 x i1> [[OV]] +; + %t = add <2 x i5> %a, + %ov = icmp slt <2 x i5> %t, + ret <2 x i1> %ov +} + +define i1 @slt_wrong_offset(i8 %a) { +; CHECK-LABEL: @slt_wrong_offset( +; CHECK-NEXT: [[T:%.*]] = add i8 [[A:%.*]], -6 +; CHECK-NEXT: [[OV:%.*]] = icmp slt i8 [[T]], -7 +; CHECK-NEXT: ret i1 [[OV]] +; + %t = add i8 %a, -6 + %ov = icmp slt i8 %t, -7 + ret i1 %ov +}