diff options
Diffstat (limited to 'llvm/test/Transforms/InstCombine/icmp.ll')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 12a4744cc0f..2e3ff24f6ba 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -1356,3 +1356,56 @@ define i1 @icmp_ashr_ashr_ne(i32 %a, i32 %b) nounwind { %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 +} |

