diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-07-02 12:54:48 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-07-02 12:54:48 +0000 |
commit | 0bde7c65275ef4fcd51bc92e1b6c280f9888b73f (patch) | |
tree | 21469a76b6790a2005c10cbe63f6036e6ed424e1 /llvm/lib/Transforms | |
parent | 6c0dcf65e7105611d4fe46e2a10629ce3c9abe5c (diff) | |
download | bcm5719-llvm-0bde7c65275ef4fcd51bc92e1b6c280f9888b73f.tar.gz bcm5719-llvm-0bde7c65275ef4fcd51bc92e1b6c280f9888b73f.zip |
[InstCombine] Shift amount reassociation: fixup constantexpr handling (PR42484)
I was actually wondering if there was some nicer way than m_Value()+cast,
but apparently what i was really "subconsciously" thinking about
was correctness issue.
hasNoUnsignedWrap()/hasNoUnsignedWrap() exist for Instruction,
not for BinaryOperator, so let's just use m_Instruction(),
thus both avoiding a cast, and a crash.
Fixes https://bugs.llvm.org/show_bug.cgi?id=42484,
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15587
llvm-svn: 364915
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index 1558795b530..0bbecde2184 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -29,12 +29,12 @@ static Instruction * reassociateShiftAmtsOfTwoSameDirectionShifts(BinaryOperator *Sh0, const SimplifyQuery &SQ) { // Look for: (x shiftopcode ShAmt0) shiftopcode ShAmt1 - Value *X, *ShAmt1, *Sh1Value, *ShAmt0; + Value *X, *ShAmt1, *ShAmt0; + Instruction *Sh1; if (!match(Sh0, m_Shift(m_CombineAnd(m_Shift(m_Value(X), m_Value(ShAmt1)), - m_Value(Sh1Value)), + m_Instruction(Sh1)), m_Value(ShAmt0)))) return nullptr; - auto *Sh1 = cast<BinaryOperator>(Sh1Value); // The shift opcodes must be identical. Instruction::BinaryOps ShiftOpcode = Sh0->getOpcode(); |