[llvm] [llvm][OpenMP][SPIRV] Fix assertion for GPU reductions (PR #194879)
Nick Sarnie via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 08:10:36 PDT 2026
================
@@ -4731,12 +4731,22 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU(
&LHSPtr, &RHSPtr, CurFunc));
// Fix the CallBack code genereated to use the correct Values for the LHS
- // and RHS
- LHSPtr->replaceUsesWithIf(RedValue, [ReductionFunc](const Use &U) {
+ // and RHS. Cast to match types before replacing (necessary to handle SPIRV address
+ // spaces).
+ Value *CastRedValue = RedValue;
+ if (LHSPtr->getType() != RedValue->getType())
+ CastRedValue = Builder.CreatePointerBitCastOrAddrSpaceCast(
----------------
sarnex wrote:
since we are just checking the types are not equal and not that they are both pointers with only difference AS, this in theory could generate a bitcast too. is that safe here?
https://github.com/llvm/llvm-project/pull/194879
More information about the llvm-commits
mailing list