[llvm] r275297 - add test for zexty xor sandwich

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 13:07:47 PDT 2016


Not sure ComputeKnownBits etc. really helps with that sort of transform? I
mean, fundamentally the basic transform we're talking about here is "x ^ 1
^ 2" <-> "x ^ 3", which is basically reassociation.

-Eli

On Wed, Jul 13, 2016 at 1:01 PM, Sanjay Patel <spatel at rotateright.com>
wrote:

> Sure. The general theme is that casts of all flavors interfere with all
> optimizations. Is the solution to use ValueTracking (computeKnownBits, etc)
> more liberally than pattern matching?
>
> On Wed, Jul 13, 2016 at 1:23 PM, Eli Friedman <eli.friedman at gmail.com>
> wrote:
>
>> On Wed, Jul 13, 2016 at 11:40 AM, Sanjay Patel via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: spatel
>>> Date: Wed Jul 13 13:40:38 2016
>>> New Revision: 275297
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=275297&view=rev
>>> Log:
>>> add test for zexty xor sandwich
>>>
>>> Modified:
>>>     llvm/trunk/test/Transforms/InstCombine/xor.ll
>>>
>>> Modified: llvm/trunk/test/Transforms/InstCombine/xor.ll
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor.ll?rev=275297&r1=275296&r2=275297&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/test/Transforms/InstCombine/xor.ll (original)
>>> +++ llvm/trunk/test/Transforms/InstCombine/xor.ll Wed Jul 13 13:40:38
>>> 2016
>>> @@ -242,6 +242,20 @@ define i32 @test22(i1 %X) {
>>>    ret i32 %Q
>>>  }
>>>
>>> +; Look through a zext between xors.
>>> +
>>> +define i32 @fold_zext_xor_sandwich(i1 %X) {
>>> +; CHECK-LABEL: @fold_zext_xor_sandwich(
>>> +; CHECK-NEXT:    [[TMP1:%.*]] = zext i1 %X to i32
>>> +; CHECK-NEXT:    [[Q:%.*]] = xor i32 [[TMP1]], 3
>>> +; CHECK-NEXT:    ret i32 [[Q]]
>>> +;
>>> +  %Y = xor i1 %X, true
>>> +  %Z = zext i1 %Y to i32
>>> +  %Q = xor i32 %Z, 2
>>> +  ret i32 %Q
>>> +}
>>>
>>>
>> You might want to write a similar testcase replacing the "xor" with an
>> "or".
>>
>> -Eli
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160713/2f490be3/attachment.html>


More information about the llvm-commits mailing list