Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ static cl::opt<bool>
DisableDeletePHIs("disable-cgp-delete-phis", cl::Hidden, cl::init(false),
cl::desc("Disable elimination of dead PHI nodes."));

namespace llvm {
extern cl::opt<bool> ProfcheckDisableMetadataFixes;
}
namespace {

enum ExtType {
Expand Down Expand Up @@ -7450,7 +7453,12 @@ bool CodeGenPrepare::optimizeShiftInst(BinaryOperator *Shift) {
BinaryOperator::BinaryOps Opcode = Shift->getOpcode();
Value *NewTVal = Builder.CreateBinOp(Opcode, Shift->getOperand(0), TVal);
Value *NewFVal = Builder.CreateBinOp(Opcode, Shift->getOperand(0), FVal);
Value *NewSel = Builder.CreateSelect(Cond, NewTVal, NewFVal);
Value *NewSel =
Builder.CreateSelect(Cond, NewTVal, NewFVal, /*Name=*/"",
/*MDFrom=*/
ProfcheckDisableMetadataFixes
? nullptr
: dyn_cast<Instruction>(Shift->getOperand(1)));
replaceAllUsesWith(Shift, NewSel, FreshBBs, IsHugeFunc);
Shift->eraseFromParent();
return true;
Expand Down Expand Up @@ -7485,7 +7493,12 @@ bool CodeGenPrepare::optimizeFunnelShift(IntrinsicInst *Fsh) {
Value *X = Fsh->getOperand(0), *Y = Fsh->getOperand(1);
Value *NewTVal = Builder.CreateIntrinsic(Opcode, Ty, {X, Y, TVal});
Value *NewFVal = Builder.CreateIntrinsic(Opcode, Ty, {X, Y, FVal});
Value *NewSel = Builder.CreateSelect(Cond, NewTVal, NewFVal);
Value *NewSel =
Builder.CreateSelect(Cond, NewTVal, NewFVal, /*Name=*/"",
/*MDFrom=*/
ProfcheckDisableMetadataFixes
? nullptr
: dyn_cast<Instruction>(Fsh->getOperand(2)));
replaceAllUsesWith(Fsh, NewSel, FreshBBs, IsHugeFunc);
Fsh->eraseFromParent();
return true;
Expand Down
Loading