diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-04-15 15:39:57 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-04-15 15:39:57 +0000 |
commit | f1aa0d7af272f5d7198c706c60214f7555aca391 (patch) | |
tree | c67278747a0c58ba848b03df87352117cc47c11e /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 525d4122c9ed09f50dee8683a14f4700cf5eb130 (diff) | |
download | bcm5719-llvm-f1aa0d7af272f5d7198c706c60214f7555aca391.tar.gz bcm5719-llvm-f1aa0d7af272f5d7198c706c60214f7555aca391.zip |
[InstCombine] simplify code for distributive property; NFCI
llvm-svn: 330096
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index a91950e8fb9..c749273723d 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -487,28 +487,12 @@ static bool RightDistributesOverLeft(Instruction::BinaryOps LOp, if (Instruction::isCommutative(ROp)) return LeftDistributesOverRight(ROp, LOp); - switch (LOp) { - default: - return false; - // (X >> Z) & (Y >> Z) -> (X&Y) >> Z for all shifts. - // (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts. - // (X >> Z) ^ (Y >> Z) -> (X^Y) >> Z for all shifts. - case Instruction::And: - case Instruction::Or: - case Instruction::Xor: - switch (ROp) { - default: - return false; - case Instruction::Shl: - case Instruction::LShr: - case Instruction::AShr: - return true; - } - } + // (X {&|^} Y) >> Z --> (X >> Z) {&|^} (Y >> Z) for all shifts. + return Instruction::isBitwiseLogicOp(LOp) && Instruction::isShift(ROp); + // TODO: It would be nice to handle division, aka "(X + Y)/Z = X/Z + Y/Z", // but this requires knowing that the addition does not overflow and other // such subtleties. - return false; } /// This function returns identity value for given opcode, which can be used to |