Skip to content

[AMDGPU] Propagate Constants for Wave Reduction Intrinsics #150395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: users/easyonaadit/amdgpu/wave-reduce-builtins
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions llvm/lib/Analysis/ConstantFolding.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,13 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
case Intrinsic::amdgcn_perm:
case Intrinsic::amdgcn_wave_reduce_umin:
case Intrinsic::amdgcn_wave_reduce_umax:
case Intrinsic::amdgcn_wave_reduce_max:
case Intrinsic::amdgcn_wave_reduce_min:
case Intrinsic::amdgcn_wave_reduce_add:
case Intrinsic::amdgcn_wave_reduce_sub:
case Intrinsic::amdgcn_wave_reduce_and:
case Intrinsic::amdgcn_wave_reduce_or:
case Intrinsic::amdgcn_wave_reduce_xor:
case Intrinsic::amdgcn_s_wqm:
case Intrinsic::amdgcn_s_quadmask:
case Intrinsic::amdgcn_s_bitreplicate:
Expand Down Expand Up @@ -3520,6 +3527,13 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
return ConstantInt::get(Ty, C0->abs());
case Intrinsic::amdgcn_wave_reduce_umin:
case Intrinsic::amdgcn_wave_reduce_umax:
case Intrinsic::amdgcn_wave_reduce_max:
case Intrinsic::amdgcn_wave_reduce_min:
case Intrinsic::amdgcn_wave_reduce_add:
case Intrinsic::amdgcn_wave_reduce_sub:
case Intrinsic::amdgcn_wave_reduce_and:
case Intrinsic::amdgcn_wave_reduce_or:
case Intrinsic::amdgcn_wave_reduce_xor:
return dyn_cast<Constant>(Operands[0]);
}

Expand Down
2,165 changes: 726 additions & 1,439 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.add.ll

Large diffs are not rendered by default.

613 changes: 135 additions & 478 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.and.ll

Large diffs are not rendered by default.

613 changes: 135 additions & 478 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.max.ll

Large diffs are not rendered by default.

613 changes: 135 additions & 478 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.min.ll

Large diffs are not rendered by default.

613 changes: 135 additions & 478 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.or.ll

Large diffs are not rendered by default.

2,393 changes: 777 additions & 1,616 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.sub.ll

Large diffs are not rendered by default.

493 changes: 111 additions & 382 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.umax.ll

Large diffs are not rendered by default.

541 changes: 135 additions & 406 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.umin.ll

Large diffs are not rendered by default.

2,121 changes: 700 additions & 1,421 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.xor.ll

Large diffs are not rendered by default.

Loading
Loading