[llvm] r330096 - [InstCombine] simplify code for distributive property; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 15 08:39:57 PDT 2018
Author: spatel
Date: Sun Apr 15 08:39:57 2018
New Revision: 330096
URL: http://llvm.org/viewvc/llvm-project?rev=330096&view=rev
Log:
[InstCombine] simplify code for distributive property; NFCI
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=330096&r1=330095&r2=330096&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sun Apr 15 08:39:57 2018
@@ -487,28 +487,12 @@ static bool RightDistributesOverLeft(Ins
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
More information about the llvm-commits
mailing list