Skip to content

Commit c3c2812

Browse files
committed
Propagate Constants for Wave Reduction Intrinsics
1 parent bc06c18 commit c3c2812

11 files changed

+3473
-7260
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

100644100755
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,13 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
16471647
case Intrinsic::amdgcn_perm:
16481648
case Intrinsic::amdgcn_wave_reduce_umin:
16491649
case Intrinsic::amdgcn_wave_reduce_umax:
1650+
case Intrinsic::amdgcn_wave_reduce_max:
1651+
case Intrinsic::amdgcn_wave_reduce_min:
1652+
case Intrinsic::amdgcn_wave_reduce_add:
1653+
case Intrinsic::amdgcn_wave_reduce_sub:
1654+
case Intrinsic::amdgcn_wave_reduce_and:
1655+
case Intrinsic::amdgcn_wave_reduce_or:
1656+
case Intrinsic::amdgcn_wave_reduce_xor:
16501657
case Intrinsic::amdgcn_s_wqm:
16511658
case Intrinsic::amdgcn_s_quadmask:
16521659
case Intrinsic::amdgcn_s_bitreplicate:
@@ -3520,6 +3527,13 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
35203527
return ConstantInt::get(Ty, C0->abs());
35213528
case Intrinsic::amdgcn_wave_reduce_umin:
35223529
case Intrinsic::amdgcn_wave_reduce_umax:
3530+
case Intrinsic::amdgcn_wave_reduce_max:
3531+
case Intrinsic::amdgcn_wave_reduce_min:
3532+
case Intrinsic::amdgcn_wave_reduce_add:
3533+
case Intrinsic::amdgcn_wave_reduce_sub:
3534+
case Intrinsic::amdgcn_wave_reduce_and:
3535+
case Intrinsic::amdgcn_wave_reduce_or:
3536+
case Intrinsic::amdgcn_wave_reduce_xor:
35233537
return dyn_cast<Constant>(Operands[0]);
35243538
}
35253539

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

Lines changed: 726 additions & 1439 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: 777 additions & 1616 deletions
Large diffs are not rendered by default.

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

Lines changed: 111 additions & 382 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: 725 additions & 1495 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)