diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-09-05 20:44:56 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-09-05 20:44:56 +0000 |
commit | daa24b978986f8a31c3bfdf47cc3556caac0917d (patch) | |
tree | bcd033de1df2f0dc1098b7645e17309011559f2f | |
parent | 311435dbb6ea8171fb228fb510c46315f54540e5 (diff) | |
download | bcm5719-llvm-daa24b978986f8a31c3bfdf47cc3556caac0917d.tar.gz bcm5719-llvm-daa24b978986f8a31c3bfdf47cc3556caac0917d.zip |
[InstCombine] Don't assume m_Mul gives back an Instruction
This fixes PR24713.
llvm-svn: 246933
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 6e4336ef875..b3366bb9888 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2246,7 +2246,9 @@ static Instruction *ProcessUMulZExtIdiom(ICmpInst &I, Value *MulVal, assert(I.getOperand(0) == MulVal || I.getOperand(1) == MulVal); assert(I.getOperand(0) == OtherVal || I.getOperand(1) == OtherVal); - Instruction *MulInstr = cast<Instruction>(MulVal); + auto *MulInstr = dyn_cast<Instruction>(MulVal); + if (!MulInstr) + return nullptr; assert(MulInstr->getOpcode() == Instruction::Mul); auto *LHS = cast<ZExtOperator>(MulInstr->getOperand(0)), diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 5d97411625e..e351c81b15a 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -1623,3 +1623,12 @@ define i1 @f9(i32 %val, i32 %lim) { %r = icmp ult i32 %val.and, %lim ret i1 %r } + +; CHECK: @f10( +; CHECK: [[CMP:%.*]] = icmp uge i16 %p, mul (i16 zext (i8 ptrtoint (i1 (i16)* @f10 to i8) to i16), i16 zext (i8 ptrtoint (i1 (i16)* @f10 to i8) to i16)) +; CHECK-NEXT: ret i1 [[CMP]] +define i1 @f10(i16 %p) { +entry: + %cmp580 = icmp ule i16 mul (i16 zext (i8 ptrtoint (i1 (i16)* @f10 to i8) to i16), i16 zext (i8 ptrtoint (i1 (i16)* @f10 to i8) to i16)), %p + ret i1 %cmp580 +} |