Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -874,6 +874,15 @@ return {NI, NL + NC + NS}; } + // Return true when I is a scalar candidate for hoisting. + bool isRelevantForHoisting(Instruction *I) { + if (isa(I) || isa(I) || isa(I) || + isa(I) || isa(I) || isa(I) || + isa(I) || isa(I)) + return false; + return true; + } + // Hoist all expressions. Returns Number of scalars hoisted // and number of non-scalars hoisted. std::pair hoistExpressions(Function &F) { @@ -916,7 +925,8 @@ // that could result in spills later. geps are handled separately. // TODO: We can relax this for targets like AArch64 as they have more // registers than X86. - II.insert(&I1, VN); + if (isRelevantForHoisting(&I1)) + II.insert(&I1, VN); } }