[llvm] r221693 - LLVM incorrectly folds xor into select

Jonathan Roelofs jonathan at codesourcery.com
Tue Nov 11 10:27:23 PST 2014



On 11/11/14 11:07 AM, Jonathan Roelofs wrote:
>
>
> On 11/11/14 11:00 AM, Tim Northover wrote:
>>>
>>> Would you mind also adding tests for what you expect these two to be lowered as:
>>>
>>> define i32 @t15_2(i32 %p1, i32 %p2, i32 %p3) {
>>> entry:
>>>   %cmp = icmp sgt i32 %p1, 8
>>>   %a = select i1 %cmp, i32 %p2, i32 %p3
>>>   %xor = xor i32 %a, -1
>>>   ret i32 %xor
>>> }
>>
>> Isn't this the test that was already added?
> No...
>
> %xor = xor i32 %a, -1
>
> vs
>
> %xor = xor i32 %a, 1
>
> Sorry I didn't call that out more explicitly.

One more, which I think the case you should actually be checking, given the 
setcc peephole that this patch is about:

define i32 @t15_4(i32 %p1, i32 %p2, i32 %p3) {
entry:
   %cmp = icmp sgt i32 %p1, 8
   %notcmp = xor i1 %cmp, 1
   %a = select i1 %notcmp, i32 %p2, i32 %p3
   ret i32 %a
}

Are there cases where the result of a setcc is not an i1?


Jon

>
>
> Cheers,
>
> Jon
>>
>> Cheers.
>>
>> Tim.
>>
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the llvm-commits mailing list