Skip to content

Commit 6fccfd7

Browse files
committed
[InstCombine] add icmp with no-wrap add tests; NFC
Goes with D100095
1 parent 14580ce commit 6fccfd7

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-add.ll

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,3 +663,75 @@ define <2 x i1> @icmp_eq_add_non_splat2(<2 x i32> %a) {
663663
%cmp = icmp eq <2 x i32> %add, <i32 10, i32 11>
664664
ret <2 x i1> %cmp
665665
}
666+
667+
define i1 @without_nsw_nuw(i8 %x, i8 %y) {
668+
; CHECK-LABEL: @without_nsw_nuw(
669+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[X:%.*]], 2
670+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[Y:%.*]]
671+
; CHECK-NEXT: ret i1 [[TOBOOL]]
672+
;
673+
%t1 = add i8 %x, 37
674+
%t2 = add i8 %y, 35
675+
%tobool = icmp eq i8 %t2, %t1
676+
ret i1 %tobool
677+
}
678+
679+
define i1 @with_nsw_nuw(i8 %x, i8 %y) {
680+
; CHECK-LABEL: @with_nsw_nuw(
681+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[X:%.*]], 2
682+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[Y:%.*]]
683+
; CHECK-NEXT: ret i1 [[TOBOOL]]
684+
;
685+
%t1 = add nsw nuw i8 %x, 37
686+
%t2 = add i8 %y, 35
687+
%tobool = icmp eq i8 %t2, %t1
688+
ret i1 %tobool
689+
}
690+
691+
define i1 @with_nsw_large(i8 %x, i8 %y) {
692+
; CHECK-LABEL: @with_nsw_large(
693+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[X:%.*]], 2
694+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[Y:%.*]]
695+
; CHECK-NEXT: ret i1 [[TOBOOL]]
696+
;
697+
%t1 = add nsw i8 %x, 37
698+
%t2 = add i8 %y, 35
699+
%tobool = icmp eq i8 %t2, %t1
700+
ret i1 %tobool
701+
}
702+
703+
define i1 @with_nsw_small(i8 %x, i8 %y) {
704+
; CHECK-LABEL: @with_nsw_small(
705+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[Y:%.*]], 2
706+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[X:%.*]]
707+
; CHECK-NEXT: ret i1 [[TOBOOL]]
708+
;
709+
%t1 = add nsw i8 %x, 35
710+
%t2 = add i8 %y, 37
711+
%tobool = icmp eq i8 %t2, %t1
712+
ret i1 %tobool
713+
}
714+
715+
define i1 @with_nuw_large(i8 %x, i8 %y) {
716+
; CHECK-LABEL: @with_nuw_large(
717+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[X:%.*]], 2
718+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[Y:%.*]]
719+
; CHECK-NEXT: ret i1 [[TOBOOL]]
720+
;
721+
%t1 = add nuw i8 %x, 37
722+
%t2 = add i8 %y, 35
723+
%tobool = icmp eq i8 %t2, %t1
724+
ret i1 %tobool
725+
}
726+
727+
define i1 @with_nuw_small(i8 %x, i8 %y) {
728+
; CHECK-LABEL: @with_nuw_small(
729+
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[Y:%.*]], 2
730+
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i8 [[TMP1]], [[X:%.*]]
731+
; CHECK-NEXT: ret i1 [[TOBOOL]]
732+
;
733+
%t1 = add nuw i8 %x, 35
734+
%t2 = add i8 %y, 37
735+
%tobool = icmp eq i8 %t2, %t1
736+
ret i1 %tobool
737+
}

0 commit comments

Comments
 (0)