mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-04 17:58:22 +00:00
Fix a recently added optimization to not crash on vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a332f17c8c
commit
39ac3b57bc
@ -3276,8 +3276,16 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
// (sdiv X, X) --> 1 (udiv X, X) --> 1
|
||||
if (Op0 == Op1)
|
||||
return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1));
|
||||
if (Op0 == Op1) {
|
||||
if (const VectorType *Ty = dyn_cast<VectorType>(I.getType())) {
|
||||
ConstantInt *CI = ConstantInt::get(Ty->getElementType(), 1);
|
||||
std::vector<Constant*> Elts(Ty->getNumElements(), CI);
|
||||
return ReplaceInstUsesWith(I, ConstantVector::get(Elts));
|
||||
}
|
||||
|
||||
ConstantInt *CI = ConstantInt::get(I.getType(), 1);
|
||||
return ReplaceInstUsesWith(I, CI);
|
||||
}
|
||||
|
||||
if (Instruction *Common = commonDivTransforms(I))
|
||||
return Common;
|
||||
|
6
test/Transforms/InstCombine/2008-05-22-IDivVector.ll
Normal file
6
test/Transforms/InstCombine/2008-05-22-IDivVector.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: llvm-as < %s | opt -instcombine -disable-output
|
||||
|
||||
define <3 x i8> @f(<3 x i8> %i) {
|
||||
%A = sdiv <3 x i8> %i, %i
|
||||
ret <3 x i8> %A
|
||||
}
|
Loading…
Reference in New Issue
Block a user