[PATCH/RFC] fold zext(setcc) into a larger setcc

Owen Anderson resistor at mac.com
Tue Jan 27 00:00:05 PST 2015


> On Jan 26, 2015, at 5:39 PM, Fiona Glaser <fglaser at apple.com> wrote:
> 
>> The aext -> select_cc here is OK, but in your patch it will combine zext (setcc) -> setcc. On a target that uses ZeroOrNegativeOneBooleanContent, that would produce a wider type with 0 upper bits which is not the same as the all 1 bits the larger compare result would give. There are also a lot of pre-existing bugs that mishandle this now that still assume 0/1 setcc results.
>> 
>> I guess I don't understand why this wouldn't already be happening during legalization if getSetCCResultType gives i32. I would not expect two different result types for the same setcc to ever work.
>> 
>> -Matt
>> 
> 
> What should one do if there are multiple valid SetCC result types?
> 
> I checked the code for the out-of-tree target, and it has i16 set to the default result type, but the target also supports i32. Is the problem that LLVM doesn’t support optimizing for the case of a target that can pick and choose its SetCC result type?

It seems like the best solution might be to optimize the sequence to SELECT_CC instead of SETCC if the type in question is not the default SETCC type for the target.  I believe you can find *that* out by checking getSetCCResultType.

—Owen



More information about the llvm-commits mailing list