diff options
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll | 325 |
1 files changed, 325 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll b/llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll index 7f616bb..a616949 100644 --- a/llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll +++ b/llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll @@ -268,3 +268,328 @@ define i1 @icmp_trunc_x_zext_y_fail_multiuse(i32 %x, i8 %y) { %r = icmp ule i16 %x16, %y16 ret i1 %r } + +define i1 @trunc_unsigned_nuw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_unsigned_nuw( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nuw i16 %y to i8 + %c = icmp ult i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_unsigned_nsw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_unsigned_nsw( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp ult i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_unsigned_both(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_unsigned_both( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw nsw i16 %x to i8 + %yt = trunc nuw nsw i16 %y to i8 + %c = icmp ult i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_unsigned_either(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_unsigned_either( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp ult i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_signed_nuw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_signed_nuw( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nuw i16 %y to i8 + %c = icmp slt i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_signed_nsw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_signed_nsw( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp slt i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_signed_both(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_signed_both( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw nsw i16 %x to i8 + %yt = trunc nuw nsw i16 %y to i8 + %c = icmp slt i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_signed_either(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_signed_either( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp slt i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_equality_nuw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_equality_nuw( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nuw i16 %y to i8 + %c = icmp eq i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_equality_nsw(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_equality_nsw( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp eq i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_equality_both(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_equality_both( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw nsw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nuw nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw nsw i16 %x to i8 + %yt = trunc nuw nsw i16 %y to i8 + %c = icmp eq i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_equality_either(i16 %x, i16 %y) { +; CHECK-LABEL: @trunc_equality_either( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i16 [[X:%.*]] to i8 +; CHECK-NEXT: [[YT:%.*]] = trunc nsw i16 [[Y:%.*]] to i8 +; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[XT]], [[YT]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i16 %x to i8 + %yt = trunc nsw i16 %y to i8 + %c = icmp eq i8 %xt, %yt + ret i1 %c +} + +define i1 @trunc_unsigned_nuw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_unsigned_nuw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ult i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp ult i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_unsigned_nuw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_unsigned_nuw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ult i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp ult i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_unsigned_nsw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_unsigned_nsw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ult i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp ult i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_unsigned_nsw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_unsigned_nsw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ult i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp ult i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_signed_nsw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_signed_nsw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp slt i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp slt i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_signed_nsw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_signed_nsw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp slt i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp slt i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_signed_nuw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_signed_nuw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp slt i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp slt i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_signed_nuw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_signed_nuw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp slt i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp slt i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_equality_nuw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_equality_nuw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ne i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp ne i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_equality_nuw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_equality_nuw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ne i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp ne i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_equality_nsw_zext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_equality_nsw_zext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = zext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ne i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = zext i8 %y to i16 + %c = icmp ne i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_equality_nsw_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_equality_nsw_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ne i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nsw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp ne i16 %xt, %ye + ret i1 %c +} + +define i1 @trunc_equality_both_sext(i32 %x, i8 %y) { +; CHECK-LABEL: @trunc_equality_both_sext( +; CHECK-NEXT: [[XT:%.*]] = trunc nuw nsw i32 [[X:%.*]] to i16 +; CHECK-NEXT: [[YE:%.*]] = sext i8 [[Y:%.*]] to i16 +; CHECK-NEXT: [[C:%.*]] = icmp ne i16 [[XT]], [[YE]] +; CHECK-NEXT: ret i1 [[C]] +; + %xt = trunc nuw nsw i32 %x to i16 + %ye = sext i8 %y to i16 + %c = icmp ne i16 %xt, %ye + ret i1 %c +} |