Skip to content

Commit

Permalink
Handle constant gep (EnzymeAD#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored May 8, 2024
1 parent ff878b5 commit 43193d6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ function nodecayed_phis!(mod::LLVM.Module)
return v2, offset, skipload
end

if isa(v, LLVM.ConstantExpr) && opcode(v) == LLVM.API.LLVMGetElementPtr && !hasload
v2, offset, skipload = getparent(operands(v)[1], offset, hasload)
offset = nuwadd!(b, offset, API.EnzymeComputeByteOffsetOfGEP(b, v, offty))
v2 = bitcast!(b, v2, LLVM.PointerType(eltype(value_type(v)), addrspace(value_type(v2))))
@assert eltype(value_type(v2)) == eltype(value_type(v))
return v2, offset, skipload
end

undeforpoison = isa(v, LLVM.UndefValue)
@static if LLVM.version() >= v"12"
undeforpoison |= isa(v, LLVM.PoisonValue)
Expand Down

0 comments on commit 43193d6

Please sign in to comment.