diff options
Diffstat (limited to 'test/Transforms/InstCombine/icmp.ll')
-rw-r--r-- | test/Transforms/InstCombine/icmp.ll | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 279d86d..64741c5 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -1522,3 +1522,54 @@ define zeroext i1 @icmp_cmpxchg_strong(i32* %sc, i32 %old_val, i32 %new_val) { %icmp = icmp eq i32 %xtrc, %old_val ret i1 %icmp } + +; CHECK-LABEL: @f1 +; CHECK-NEXT: %[[cmp:.*]] = icmp sge i64 %a, %b +; CHECK-NEXT: ret i1 %[[cmp]] +define i1 @f1(i64 %a, i64 %b) { + %t = sub nsw i64 %a, %b + %v = icmp sge i64 %t, 0 + ret i1 %v +} + +; CHECK-LABEL: @f2 +; CHECK-NEXT: %[[cmp:.*]] = icmp sgt i64 %a, %b +; CHECK-NEXT: ret i1 %[[cmp]] +define i1 @f2(i64 %a, i64 %b) { + %t = sub nsw i64 %a, %b + %v = icmp sgt i64 %t, 0 + ret i1 %v +} + +; CHECK-LABEL: @f3 +; CHECK-NEXT: %[[cmp:.*]] = icmp slt i64 %a, %b +; CHECK-NEXT: ret i1 %[[cmp]] +define i1 @f3(i64 %a, i64 %b) { + %t = sub nsw i64 %a, %b + %v = icmp slt i64 %t, 0 + ret i1 %v +} + +; CHECK-LABEL: @f4 +; CHECK-NEXT: %[[cmp:.*]] = icmp sle i64 %a, %b +; CHECK-NEXT: ret i1 %[[cmp]] +define i1 @f4(i64 %a, i64 %b) { + %t = sub nsw i64 %a, %b + %v = icmp sle i64 %t, 0 + ret i1 %v +} + +; CHECK-LABEL: @f5 +; CHECK: %[[cmp:.*]] = icmp slt i32 %[[sub:.*]], 0 +; CHECK: %[[neg:.*]] = sub nsw i32 0, %[[sub]] +; CHECK: %[[sel:.*]] = select i1 %[[cmp]], i32 %[[neg]], i32 %[[sub]] +; CHECK: ret i32 %[[sel]] +define i32 @f5(i8 %a, i8 %b) { + %conv = zext i8 %a to i32 + %conv3 = zext i8 %b to i32 + %sub = sub nsw i32 %conv, %conv3 + %cmp4 = icmp slt i32 %sub, 0 + %sub7 = sub nsw i32 0, %sub + %sub7.sub = select i1 %cmp4, i32 %sub7, i32 %sub + ret i32 %sub7.sub +} |