mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
Reorder shuffle and binary operation.
This patch enables transformations:
BinOp(shuffle(v1), shuffle(v2)) -> shuffle(BinOp(v1, v2))
BinOp(shuffle(v1), const1) -> shuffle(BinOp, const2)
They allow to eliminate extra shuffles in some cases.
Differential Revision: http://reviews.llvm.org/D3525
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -120,6 +120,9 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
||||
bool Changed = SimplifyAssociativeOrCommutative(I);
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifyMulInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -428,6 +431,9 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
|
||||
bool Changed = SimplifyAssociativeOrCommutative(I);
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (isa<Constant>(Op0))
|
||||
std::swap(Op0, Op1);
|
||||
|
||||
@@ -878,6 +884,9 @@ static size_t visitUDivOperand(Value *Op0, Value *Op1, const BinaryOperator &I,
|
||||
Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifyUDivInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -937,6 +946,9 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
|
||||
Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifySDivInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -1023,6 +1035,9 @@ static Instruction *CvtFDivConstToReciprocal(Value *Dividend,
|
||||
Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifyFDivInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -1185,6 +1200,9 @@ Instruction *InstCombiner::commonIRemTransforms(BinaryOperator &I) {
|
||||
Instruction *InstCombiner::visitURem(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifyURemInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -1217,6 +1235,9 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) {
|
||||
Instruction *InstCombiner::visitSRem(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifySRemInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
@@ -1288,6 +1309,9 @@ Instruction *InstCombiner::visitSRem(BinaryOperator &I) {
|
||||
Instruction *InstCombiner::visitFRem(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
if (Value *V = SimplifyVectorOp(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (Value *V = SimplifyFRemInst(Op0, Op1, DL))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user