[llvm] r275297 - add test for zexty xor sandwich

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 16:34:48 PDT 2016


Yes, you're right. I was imagining some kind of extension of
SimplifyDemandedBits because it does get this case:
define i32 @or_z_or(i8 %a) {
  %or1 = or i8 %a, 3
  %z = zext i8 %or1 to i32
  %or2 = or i32 %z, 3   <--- same constant
  ret i32 %or2
}

...but it looks like we're missing a general 'associative operators
interrupted by a cast op' transform, so I'll work on a pattern match for
that.


On Wed, Jul 13, 2016 at 2:07 PM, Eli Friedman <eli.friedman at gmail.com>
wrote:

> 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/7954b0bc/attachment.html>


More information about the llvm-commits mailing list