Skip to content

Commit bdebbd9

Browse files
authored
[AMDGPU] Propagate Constants for Wave Reduction Intrinsics (#150395)
1 parent 62f2641 commit bdebbd9

11 files changed

+3605
-7332
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

100644100755
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,13 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
16521652
case Intrinsic::amdgcn_perm:
16531653
case Intrinsic::amdgcn_wave_reduce_umin:
16541654
case Intrinsic::amdgcn_wave_reduce_umax:
1655+
case Intrinsic::amdgcn_wave_reduce_max:
1656+
case Intrinsic::amdgcn_wave_reduce_min:
1657+
case Intrinsic::amdgcn_wave_reduce_add:
1658+
case Intrinsic::amdgcn_wave_reduce_sub:
1659+
case Intrinsic::amdgcn_wave_reduce_and:
1660+
case Intrinsic::amdgcn_wave_reduce_or:
1661+
case Intrinsic::amdgcn_wave_reduce_xor:
16551662
case Intrinsic::amdgcn_s_wqm:
16561663
case Intrinsic::amdgcn_s_quadmask:
16571664
case Intrinsic::amdgcn_s_bitreplicate:
@@ -3672,6 +3679,13 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
36723679
return ConstantInt::get(Ty, C0->abs());
36733680
case Intrinsic::amdgcn_wave_reduce_umin:
36743681
case Intrinsic::amdgcn_wave_reduce_umax:
3682+
case Intrinsic::amdgcn_wave_reduce_max:
3683+
case Intrinsic::amdgcn_wave_reduce_min:
3684+
case Intrinsic::amdgcn_wave_reduce_add:
3685+
case Intrinsic::amdgcn_wave_reduce_sub:
3686+
case Intrinsic::amdgcn_wave_reduce_and:
3687+
case Intrinsic::amdgcn_wave_reduce_or:
3688+
case Intrinsic::amdgcn_wave_reduce_xor:
36753689
return dyn_cast<Constant>(Operands[0]);
36763690
}
36773691

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.add.ll

Lines changed: 783 additions & 1553 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.and.ll

Lines changed: 135 additions & 478 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.max.ll

Lines changed: 135 additions & 478 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.min.ll

Lines changed: 135 additions & 478 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.or.ll

Lines changed: 135 additions & 478 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.sub.ll

Lines changed: 856 additions & 1764 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.umax.ll

Lines changed: 132 additions & 266 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.umin.ll

Lines changed: 135 additions & 406 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.reduce.xor.ll

Lines changed: 700 additions & 1421 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)