[PATCH] D31686: [InstCombine] Support folding a subtract with a constant LHS into a phi node
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 16:56:49 PDT 2017
craig.topper created this revision.
We currently only support folding a subtract into a select but not a PHI. This fixes that.
I had to fix an assumption in FoldOpIntoPhi that assumed the PHI node was always in operand 0. Now we pass it in like we do for FoldOpIntoSelect. But we still require some dancing to find the Constant when we create the BinOp or ConstantExpr. This is based code is similar to what we do for selects.
https://reviews.llvm.org/D31686
Files:
lib/Transforms/InstCombine/InstCombineAddSub.cpp
lib/Transforms/InstCombine/InstCombineCasts.cpp
lib/Transforms/InstCombine/InstCombineCompares.cpp
lib/Transforms/InstCombine/InstCombineInternal.h
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
lib/Transforms/InstCombine/InstCombineSelect.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/sub.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31686.94139.patch
Type: text/x-patch
Size: 10112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170404/e9814241/attachment.bin>
More information about the llvm-commits
mailing list