1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 ; --------------------------------------------------------------------
5 ; llvm.amdgcn.wave.reduce.umin.i32
6 ; --------------------------------------------------------------------
8 declare i32 @llvm.amdgcn.wave.reduce.umin.i32(i32, i32 immarg)
10 define amdgpu_kernel void @test_constant_fold_wave_reduce_umin_poison(ptr addrspace(1) %out, i32 %in) {
11 ; CHECK-LABEL: @test_constant_fold_wave_reduce_umin_poison(
13 ; CHECK-NEXT: store i32 poison, ptr addrspace(1) [[OUT:%.*]], align 4
14 ; CHECK-NEXT: ret void
17 %result = call i32 @llvm.amdgcn.wave.reduce.umin.i32(i32 poison, i32 1)
18 store i32 %result, ptr addrspace(1) %out
22 define amdgpu_kernel void @test_constant_fold_wave_reduce_umin_const(ptr addrspace(1) %out) {
23 ; CHECK-LABEL: @test_constant_fold_wave_reduce_umin_const(
25 ; CHECK-NEXT: store i32 123, ptr addrspace(1) [[OUT:%.*]], align 4
26 ; CHECK-NEXT: ret void
29 %result = call i32 @llvm.amdgcn.wave.reduce.umin.i32(i32 123, i32 1)
30 store i32 %result, ptr addrspace(1) %out
34 ; --------------------------------------------------------------------
35 ; llvm.amdgcn.wave.reduce.umin.i32
36 ; --------------------------------------------------------------------
38 declare i32 @llvm.amdgcn.wave.reduce.umax.i32(i32, i32 immarg)
40 define amdgpu_kernel void @test_constant_fold_wave_reduce_umax_poison(ptr addrspace(1) %out, i32 %in) {
41 ; CHECK-LABEL: @test_constant_fold_wave_reduce_umax_poison(
43 ; CHECK-NEXT: store i32 poison, ptr addrspace(1) [[OUT:%.*]], align 4
44 ; CHECK-NEXT: ret void
47 %result = call i32 @llvm.amdgcn.wave.reduce.umax.i32(i32 poison, i32 1)
48 store i32 %result, ptr addrspace(1) %out
52 define amdgpu_kernel void @test_constant_fold_wave_reduce_umax_const(ptr addrspace(1) %out) {
53 ; CHECK-LABEL: @test_constant_fold_wave_reduce_umax_const(
55 ; CHECK-NEXT: store i32 123, ptr addrspace(1) [[OUT:%.*]], align 4
56 ; CHECK-NEXT: ret void
59 %result = call i32 @llvm.amdgcn.wave.reduce.umax.i32(i32 123, i32 1)
60 store i32 %result, ptr addrspace(1) %out
65 define amdgpu_kernel void @test_constant_fold_wave_reduce_umax_gv(ptr addrspace(1) %out) {
66 ; CHECK-LABEL: @test_constant_fold_wave_reduce_umax_gv(
68 ; CHECK-NEXT: [[RESULT:%.*]] = call i32 @llvm.amdgcn.wave.reduce.umax.i32(i32 ptrtoint (ptr @gv to i32), i32 1)
69 ; CHECK-NEXT: store i32 [[RESULT]], ptr addrspace(1) [[OUT:%.*]], align 4
70 ; CHECK-NEXT: ret void
73 %result = call i32 @llvm.amdgcn.wave.reduce.umax.i32(i32 ptrtoint (ptr @gv to i32), i32 1)
74 store i32 %result, ptr addrspace(1) %out