Skip to content

Commit 2bfb955

Browse files
committed
[InstCombine] rename variable for readability; NFC
There's more that can be done here, but "OpI" doesn't convey that we casted to BinaryOperator. llvm-svn: 371682
1 parent ffe5466 commit 2bfb955

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -1531,16 +1531,16 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
15311531
// what we can and cannot do safely varies from operation to operation, and
15321532
// is explained below in the various case statements.
15331533
Type *Ty = FPT.getType();
1534-
BinaryOperator *OpI = dyn_cast<BinaryOperator>(FPT.getOperand(0));
1535-
if (OpI && OpI->hasOneUse()) {
1536-
Type *LHSMinType = getMinimumFPType(OpI->getOperand(0));
1537-
Type *RHSMinType = getMinimumFPType(OpI->getOperand(1));
1538-
unsigned OpWidth = OpI->getType()->getFPMantissaWidth();
1534+
auto *BO = dyn_cast<BinaryOperator>(FPT.getOperand(0));
1535+
if (BO && BO->hasOneUse()) {
1536+
Type *LHSMinType = getMinimumFPType(BO->getOperand(0));
1537+
Type *RHSMinType = getMinimumFPType(BO->getOperand(1));
1538+
unsigned OpWidth = BO->getType()->getFPMantissaWidth();
15391539
unsigned LHSWidth = LHSMinType->getFPMantissaWidth();
15401540
unsigned RHSWidth = RHSMinType->getFPMantissaWidth();
15411541
unsigned SrcWidth = std::max(LHSWidth, RHSWidth);
15421542
unsigned DstWidth = Ty->getFPMantissaWidth();
1543-
switch (OpI->getOpcode()) {
1543+
switch (BO->getOpcode()) {
15441544
default: break;
15451545
case Instruction::FAdd:
15461546
case Instruction::FSub:
@@ -1563,10 +1563,10 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
15631563
// could be tightened for those cases, but they are rare (the main
15641564
// case of interest here is (float)((double)float + float)).
15651565
if (OpWidth >= 2*DstWidth+1 && DstWidth >= SrcWidth) {
1566-
Value *LHS = Builder.CreateFPTrunc(OpI->getOperand(0), Ty);
1567-
Value *RHS = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
1568-
Instruction *RI = BinaryOperator::Create(OpI->getOpcode(), LHS, RHS);
1569-
RI->copyFastMathFlags(OpI);
1566+
Value *LHS = Builder.CreateFPTrunc(BO->getOperand(0), Ty);
1567+
Value *RHS = Builder.CreateFPTrunc(BO->getOperand(1), Ty);
1568+
Instruction *RI = BinaryOperator::Create(BO->getOpcode(), LHS, RHS);
1569+
RI->copyFastMathFlags(BO);
15701570
return RI;
15711571
}
15721572
break;
@@ -1577,9 +1577,9 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
15771577
// rounding can possibly occur; we can safely perform the operation
15781578
// in the destination format if it can represent both sources.
15791579
if (OpWidth >= LHSWidth + RHSWidth && DstWidth >= SrcWidth) {
1580-
Value *LHS = Builder.CreateFPTrunc(OpI->getOperand(0), Ty);
1581-
Value *RHS = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
1582-
return BinaryOperator::CreateFMulFMF(LHS, RHS, OpI);
1580+
Value *LHS = Builder.CreateFPTrunc(BO->getOperand(0), Ty);
1581+
Value *RHS = Builder.CreateFPTrunc(BO->getOperand(1), Ty);
1582+
return BinaryOperator::CreateFMulFMF(LHS, RHS, BO);
15831583
}
15841584
break;
15851585
case Instruction::FDiv:
@@ -1590,9 +1590,9 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
15901590
// condition used here is a good conservative first pass.
15911591
// TODO: Tighten bound via rigorous analysis of the unbalanced case.
15921592
if (OpWidth >= 2*DstWidth && DstWidth >= SrcWidth) {
1593-
Value *LHS = Builder.CreateFPTrunc(OpI->getOperand(0), Ty);
1594-
Value *RHS = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
1595-
return BinaryOperator::CreateFDivFMF(LHS, RHS, OpI);
1593+
Value *LHS = Builder.CreateFPTrunc(BO->getOperand(0), Ty);
1594+
Value *RHS = Builder.CreateFPTrunc(BO->getOperand(1), Ty);
1595+
return BinaryOperator::CreateFDivFMF(LHS, RHS, BO);
15961596
}
15971597
break;
15981598
case Instruction::FRem: {
@@ -1604,14 +1604,14 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
16041604
break;
16051605
Value *LHS, *RHS;
16061606
if (LHSWidth == SrcWidth) {
1607-
LHS = Builder.CreateFPTrunc(OpI->getOperand(0), LHSMinType);
1608-
RHS = Builder.CreateFPTrunc(OpI->getOperand(1), LHSMinType);
1607+
LHS = Builder.CreateFPTrunc(BO->getOperand(0), LHSMinType);
1608+
RHS = Builder.CreateFPTrunc(BO->getOperand(1), LHSMinType);
16091609
} else {
1610-
LHS = Builder.CreateFPTrunc(OpI->getOperand(0), RHSMinType);
1611-
RHS = Builder.CreateFPTrunc(OpI->getOperand(1), RHSMinType);
1610+
LHS = Builder.CreateFPTrunc(BO->getOperand(0), RHSMinType);
1611+
RHS = Builder.CreateFPTrunc(BO->getOperand(1), RHSMinType);
16121612
}
16131613

1614-
Value *ExactResult = Builder.CreateFRemFMF(LHS, RHS, OpI);
1614+
Value *ExactResult = Builder.CreateFRemFMF(LHS, RHS, BO);
16151615
return CastInst::CreateFPCast(ExactResult, Ty);
16161616
}
16171617
}

0 commit comments

Comments
 (0)