1
+ ;; Test reduction of:
2
+ ;;
3
+ ;; DST = shl i64 X, Y
4
+ ;;
5
+ ;; where Y is in the range [63-32] to:
6
+ ;;
7
+ ;; DST = [shl i32 X, (Y - 32), 0]
8
+
1
9
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
2
10
3
11
4
12
target triple = "amdgcn-amd-amdhsa"
5
13
14
+ ; Test reduction where range information comes from meta-data
6
15
define i64 @func_range (i64 noundef %arg0 , ptr %arg1.ptr ) {
7
16
%shift.amt = load i64 , ptr %arg1.ptr , !range !0
8
17
%shl = shl i64 %arg0 , %shift.amt
@@ -21,11 +30,19 @@ define i64 @func_range(i64 noundef %arg0, ptr %arg1.ptr) {
21
30
}
22
31
!0 = !{i64 32 , i64 64 }
23
32
33
+ ; FIXME: This case should be reduced too, but computeKnownBits() cannot
34
+ ; determine the range. Match current results for now.
24
35
define i64 @func_max (i64 noundef %arg0 , i64 noundef %arg1 ) {
25
36
%max = call i64 @llvm.umax.i64 (i64 %arg1 , i64 32 )
26
37
%min = call i64 @llvm.umin.i64 (i64 %max , i64 63 )
27
38
%shl = shl i64 %arg0 , %min
28
39
ret i64 %shl
40
+
41
+ ; CHECK: define i64 @func_max(i64 noundef %arg0, i64 noundef %arg1) {
42
+ ; CHECK: %max = call i64 @llvm.umax.i64(i64 %arg1, i64 32)
43
+ ; CHECK: %min = call i64 @llvm.umin.i64(i64 %max, i64 63)
44
+ ; CHECK: %shl = shl i64 %arg0, %min
45
+ ; CHECK: ret i64 %shl
29
46
}
30
47
31
48
0 commit comments