HomePhabricator

[InstCombine] New opportunities for FoldAndOfICmp and FoldXorOfICmp

Description

[InstCombine] New opportunities for FoldAndOfICmp and FoldXorOfICmp

A number of new patterns for simplifying and/xor of icmp:

(icmp ne %x, 0) ^ (icmp ne %y, 0) => icmp ne %x, %y if the following is true:
1- (%x = and %a, %mask) and (%y = and %b, %mask)
2- %mask is a power of 2.

(icmp eq %x, 0) & (icmp ne %y, 0) => icmp ult %x, %y if the following is true:
1- (%x = and %a, %mask1) and (%y = and %b, %mask2)
2- Let %t be the smallest power of 2 where %mask1 & %t != 0. Then for any

%s that is a power of 2 and %s & %mask2 != 0, we must have %s <= %t.

For example if %mask1 = 24 and %mask2 = 16, setting %s = 16 and %t = 8
violates condition (2) above. So this optimization cannot be applied.

Details

Committed
amehsanDec 15 2016, 4:25 AM
Parents
rL289812: Revert "[TESTS] Initial commit of tests, by Andrew Tischenko"
Branches
Unknown
Tags
Unknown