[PATCH] InstCombine: Improve the result bitvect type when folding (cmp pred (load (gep GV, i)) C) to a bit test.

Ahmed Bougacha ahmed.bougacha at gmail.com
Thu Mar 21 06:28:46 PDT 2013


Hi all,

This patch makes InstCombine choose better types when folding (cmp
pred (load (gep GV, i)) C) to a bit test (((bitvector >> i) & 1) !=
0).

As the commit says:

> The original code used i32, and i64 if legal. This introduced unneeded
> casts when they aren't legal, or when the index variable i has another
> type. In order of preference: try to use i's type, looking past a cast
> if there is one; use the smallest fitting legal type (using an added
> DataLayout method); default to i32.
> A testcase checks that this works when everything is i16.

I'm not convinced about adding DataLayout::getSmallestLegalIntType,
but it seemed like the natural way to do it (mirrorring
isLegalInteger).

Thanks,

-- Ahmed Bougacha
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-InstCombine-Improve-the-result-bitvect-type-when-fol.patch
Type: application/octet-stream
Size: 6100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130321/ef1889bc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-InstCombine-Improve-the-result-bitvect-type-when-fol.patch
Type: application/octet-stream
Size: 6100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130321/ef1889bc/attachment-0001.obj>


More information about the llvm-commits mailing list