Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit e523817

Browse files
author
Max Kazantsev
committed
[NFC] Test that shows unprofitability of instcombine with bit ranges
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336078 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 25c9ed7 commit e523817

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -instcombine -S < %s | FileCheck %s
3+
4+
; Test that presence of range does not cause unprofitable transforms with bit
5+
; arithmetics, and instcombine behaves exactly the same as without the range.
6+
7+
define i1 @without_range(i32* %A) {
8+
; CHECK-LABEL: @without_range(
9+
; CHECK-NEXT: [[A_VAL:%.*]] = load i32, i32* [[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, i32* %A, align 8
14+
%B = sdiv i32 %A.val, 2
15+
%C = icmp sge i32 0, %B
16+
ret i1 %C
17+
}
18+
19+
define i1 @with_range(i32* %A) {
20+
; CHECK-LABEL: @with_range(
21+
; CHECK-NEXT: [[A_VAL:%.*]] = load i32, i32* [[A:%.*]], align 8, !range !0
22+
; CHECK-NEXT: [[B_MASK:%.*]] = and i32 [[A_VAL]], 2147483646
23+
; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B_MASK]], 0
24+
; CHECK-NEXT: ret i1 [[C]]
25+
;
26+
%A.val = load i32, i32* %A, align 8, !range !0
27+
%B = sdiv i32 %A.val, 2
28+
%C = icmp sge i32 0, %B
29+
ret i1 %C
30+
}
31+
32+
!0 = !{i32 0, i32 2147483647}

0 commit comments

Comments
 (0)