Skip to content

Commit 065fb26

Browse files
committed
Propagate Constants for Wave Reduction Intrinsics
1 parent 34355ed commit 065fb26

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:
@@ -3525,6 +3532,13 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
35253532
return ConstantInt::get(Ty, C0->abs());
35263533
case Intrinsic::amdgcn_wave_reduce_umin:
35273534
case Intrinsic::amdgcn_wave_reduce_umax:
3535+
case Intrinsic::amdgcn_wave_reduce_max:
3536+
case Intrinsic::amdgcn_wave_reduce_min:
3537+
case Intrinsic::amdgcn_wave_reduce_add:
3538+
case Intrinsic::amdgcn_wave_reduce_sub:
3539+
case Intrinsic::amdgcn_wave_reduce_and:
3540+
case Intrinsic::amdgcn_wave_reduce_or:
3541+
case Intrinsic::amdgcn_wave_reduce_xor:
35283542
return dyn_cast<Constant>(Operands[0]);
35293543
}
35303544

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)