Skip to content

Commit 736c1e1

Browse files
committed
Add checks for case where range comes from min/max calls
Signed-off-by: John Lu <[email protected]>
1 parent 8c63a11 commit 736c1e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llvm/test/Transforms/InstCombine/shl64-reduce.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
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+
19
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
210

311

412
target triple = "amdgcn-amd-amdhsa"
513

14+
; Test reduction where range information comes from meta-data
615
define i64 @func_range(i64 noundef %arg0, ptr %arg1.ptr) {
716
%shift.amt = load i64, ptr %arg1.ptr, !range !0
817
%shl = shl i64 %arg0, %shift.amt
@@ -21,11 +30,19 @@ define i64 @func_range(i64 noundef %arg0, ptr %arg1.ptr) {
2130
}
2231
!0 = !{i64 32, i64 64}
2332

33+
; FIXME: This case should be reduced too, but computeKnownBits() cannot
34+
; determine the range. Match current results for now.
2435
define i64 @func_max(i64 noundef %arg0, i64 noundef %arg1) {
2536
%max = call i64 @llvm.umax.i64(i64 %arg1, i64 32)
2637
%min = call i64 @llvm.umin.i64(i64 %max, i64 63)
2738
%shl = shl i64 %arg0, %min
2839
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
2946
}
3047

3148

0 commit comments

Comments
 (0)