%z = icmp ne i32 %x, %y
ret i1 %z
}
+
+; CHECK-LABEL: icmp_add_const_const1
+; CHECK: %cmp = icmp slt i32 %x, -10
+; CHECK-NOT: %add = add nsw i32 %x, 10
+define i32 @icmp_add_const_const1(i32 %x) nounwind ssp uwtable {
+entry:
+ %add = add nsw i32 %x, 10
+ %cmp = icmp slt i32 %add, 0
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+; CHECK-LABEL: icmp_add_const_const2
+; CHECK: %cmp = icmp slt i32 %x, -10
+; CHECK-NOT: %add = add nsw i32 %x, 10
+define i32 @icmp_add_const_const2(i32 %x) nounwind ssp uwtable {
+entry:
+ %add = add nsw i32 10, %x
+ %cmp = icmp sgt i32 0, %add
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+; CHECK-LABEL: icmp_add_const_const3
+; CHECK: %cmp = icmp slt i32 %x, 20
+; CHECK-NOT: %sub = add nsw i32 %x, -10
+define i32 @icmp_add_const_const3(i32 %x) nounwind ssp uwtable {
+entry:
+ %add = add nsw i32 -10, %x
+ %cmp = icmp sgt i32 10, %add
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+; CHECK-LABEL: icmp_add_const_intmin
+; CHECK: %cmp = icmp ne i32 %x, 2147483638
+define i32 @icmp_add_const_intmin(i32 %x) nounwind ssp uwtable {
+entry:
+ %add = add nsw i32 %x, 10
+ %cmp = icmp sgt i32 %add, -2147483648
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+; CHECK-LABEL: icmp_add_const_intmax
+; CHECK: %cmp = icmp ne i32 %x, 2147483637
+define i32 @icmp_add_const_intmax(i32 %x) nounwind ssp uwtable {
+entry:
+ %add = add nsw i32 %x, 10
+ %cmp = icmp slt i32 %add, 2147483647
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}