xref: /llvm-project/llvm/test/Transforms/ConstraintElimination/overflows.ll (revision 821c332b53db9818d193bf4813d00db1485e35c8)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
3
4define i1 @test_overflow_sub_coefficients(i8 %x, i64 %y) {
5; CHECK-LABEL: define i1 @test_overflow_sub_coefficients
6; CHECK-SAME: (i8 [[X:%.*]], i64 [[Y:%.*]]) {
7; CHECK-NEXT:  bb:
8; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X]] to i64
9; CHECK-NEXT:    [[SHL:%.*]] = shl nuw nsw i64 [[ZEXT]], 63
10; CHECK-NEXT:    [[ICMP:%.*]] = icmp uge i64 [[SHL]], [[Y]]
11; CHECK-NEXT:    ret i1 [[ICMP]]
12;
13bb:
14  %zext = zext i8 %x to i64
15  %shl = shl nuw nsw i64 %zext, 63
16  %icmp = icmp uge i64 %shl, %y
17  ret i1 %icmp
18}
19
20define i1 @test_overflow_in_negate_constraint(i8 %x, i64 %y) {
21; CHECK-LABEL: define i1 @test_overflow_in_negate_constraint
22; CHECK-SAME: (i8 [[X:%.*]], i64 [[Y:%.*]]) {
23; CHECK-NEXT:  bb:
24; CHECK-NEXT:    [[ZEXT:%.*]] = zext i8 [[X]] to i64
25; CHECK-NEXT:    [[SHL:%.*]] = shl nuw nsw i64 [[ZEXT]], 63
26; CHECK-NEXT:    [[ICMP:%.*]] = icmp uge i64 [[Y]], [[SHL]]
27; CHECK-NEXT:    ret i1 [[ICMP]]
28;
29bb:
30  %zext = zext i8 %x to i64
31  %shl = shl nuw nsw i64 %zext, 63
32  %icmp = icmp uge i64 %y, %shl
33  ret i1 %icmp
34}
35
36