[llvm] r369207 - [InstCombine] Cherry-pick NFC cleanups of foldShiftIntoShiftInAnotherHandOfAndInICmp() from D66383
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 05:26:34 PDT 2019
Author: lebedevri
Date: Sun Aug 18 05:26:33 2019
New Revision: 369207
URL: http://llvm.org/viewvc/llvm-project?rev=369207&view=rev
Log:
[InstCombine] Cherry-pick NFC cleanups of foldShiftIntoShiftInAnotherHandOfAndInICmp() from D66383
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=369207&r1=369206&r2=369207&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Sun Aug 18 05:26:33 2019
@@ -3321,12 +3321,15 @@ foldShiftIntoShiftInAnotherHandOfAndInIC
m_Instruction(MaybeTruncation)))))
return nullptr;
- Instruction *UntruncatedShift = XShift;
-
// We potentially looked past 'trunc', but only when matching YShift,
// therefore YShift must have the widest type.
- Type *WidestTy = YShift->getType();
- assert(XShift->getType() == I.getOperand(0)->getType() &&
+ Instruction *WidestShift = YShift;
+ // Therefore XShift must have the shallowest type.
+ // Or they both have identical types if there was no truncation.
+ Instruction *NarrowestShift = XShift;
+
+ Type *WidestTy = WidestShift->getType();
+ assert(NarrowestShift->getType() == I.getOperand(0)->getType() &&
"We did not look past any shifts while matching XShift though.");
bool HadTrunc = WidestTy != I.getOperand(0)->getType();
@@ -3363,7 +3366,7 @@ foldShiftIntoShiftInAnotherHandOfAndInIC
// Due to the 'trunc', we will need to widen X. For that either the old
// 'trunc' or the shift amt in the non-truncated shift should be one-use.
if (!MaybeTruncation->hasOneUse() &&
- !UntruncatedShift->getOperand(1)->hasOneUse())
+ !NarrowestShift->getOperand(1)->hasOneUse())
return nullptr;
}
}
More information about the llvm-commits
mailing list