[llvm-commits] [llvm] r170226 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/fast-math.ll
Michael Ilseman
milseman at apple.com
Mon Dec 17 15:34:31 PST 2012
On Dec 17, 2012, at 9:51 AM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> Your proposed transformation:
> X op (select cond A, B) -> select cond (X op A), (X op B)
> could improve performance iff *BOTH* "X op A" and "X op B" don't need extra instructions to evaluate their value.
>
Note that "not needing extra instructions" is exactly the way the SimplifyInstruction APIs are set up (e.g. SimplifyFMul). If they return non-0, then the expression has been reduced. You might be able to both clean up your code and generalize it a little bit this way.
See if the following works or is reasonable:
…
if (A = SimplifyFMul(SLHS, X, …)) && (B = SimplifyFMul(SRHS, X, …)) {
… create a new select between A and B …
}
> Other than the "cond ? 1 : 0" expression, It is hard to imagine real-world applications have such opportunities.
>
>
> On 12/16/12 8:49 AM, Duncan Sands wrote:
>> Hi Shuxin,
>>
>> On 14/12/12 19:46, Shuxin Yang wrote:
>>> Author: shuxin_yang
>>> Date: Fri Dec 14 12:46:06 2012
>>> New Revision: 170226
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=170226&view=rev
>>> Log:
>>> rdar://12753946
>>>
>>> Implement rule : "x * (select cond 1.0, 0.0) -> select cond x, 0.0"
>>
>> this is a special case of:
>>
>> X op (select cond A, B) -> select cond (X op A), (X op B)
>>
>> when X op A and X op B simplify (for example because passing X op A and
>> X op B to InstructionSimplify say that they simplify). Any chance of
>> implementing this more general transform instead?
>>
>> Thanks, Duncan.
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list