xref: /llvm-project/llvm/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll (revision 095d49da76be09143582e07a807c86d3b4334dec)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3
4; Test that presence of range does not cause unprofitable transforms with bit
5; arithmetics.
6
7define i1 @without_range(ptr %A) {
8; CHECK-LABEL: @without_range(
9; CHECK-NEXT:    [[A_VAL:%.*]] = load i32, ptr [[A:%.*]], align 8
10; CHECK-NEXT:    [[C:%.*]] = icmp slt i32 [[A_VAL]], 2
11; CHECK-NEXT:    ret i1 [[C]]
12;
13  %A.val = load i32, ptr %A, align 8
14  %B = sdiv i32 %A.val, 2
15  %C = icmp sge i32 0, %B
16  ret i1 %C
17}
18
19define i1 @with_range(ptr %A) {
20; CHECK-LABEL: @with_range(
21; CHECK-NEXT:    [[A_VAL:%.*]] = load i32, ptr [[A:%.*]], align 8, !range [[RNG0:![0-9]+]]
22; CHECK-NEXT:    [[C:%.*]] = icmp samesign ult i32 [[A_VAL]], 2
23; CHECK-NEXT:    ret i1 [[C]]
24;
25  %A.val = load i32, ptr %A, align 8, !range !0
26  %B = sdiv i32 %A.val, 2
27  %C = icmp sge i32 0, %B
28  ret i1 %C
29}
30
31!0 = !{i32 0, i32 2147483647}
32