Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -913,7 +913,8 @@ break; CI.insert(Call, VN); - } else if (HoistingGeps || !isa(&I1)) + } else if (!isa(&I1) && + (HoistingGeps || !isa(&I1))) // Do not hoist scalars past calls that may write to memory because // that could result in spills later. geps are handled separately. // TODO: We can relax this for targets like AArch64 as they have more