[PATCH] InstCombine: Combine two icmps into one if the RHSs agree
Meador Inge
meadori at codesourcery.com
Fri Aug 1 10:38:06 PDT 2014
On 07/31/2014 01:27 PM, David Majnemer wrote:
> consider:
> %cmp1 = icmp CC %V1, C
> %cmp2 = icmp CC %V2, C
> %and = and %cmp1, %cmp2
>
> we can transform this into:
> %or = or %V1, %V2
> %cmp = icmp CC %or, C
Maybe I am missing something, but this transformation seems invalid.
Consider CC = eq, V1 = 1, V2 = 3, C = 3:
%cmp1 = icmp eq %V1, 3
%cmp2 = icmp eq %V2, 3
%and = and %cmp1, %cmp2
Therefore and = 0.
Now consider the optimized sequence:
%or = or %V1, %V2
%cmp = icmp eq %or, 3
In this case cmp = 1, which is incorrect.
--
Meador Inge
CodeSourcery / Mentor Embedded
More information about the llvm-commits
mailing list