mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
InstCombine: Improve the result bitvect type when folding (cmp pred (load (gep GV, i)) C) to a bit test.
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; use the smallest fitting legal type (using an added DataLayout method); default to i32. A testcase checks that this works when the index gep operand is i16. Patch by : Ahmed Bougacha <ahmed.bougacha@gmail.com> Reviewed by : Duncan git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -621,6 +621,13 @@ Type *DataLayout::getIntPtrType(Type *Ty) const {
|
||||
return IntTy;
|
||||
}
|
||||
|
||||
Type *DataLayout::getSmallestLegalIntType(LLVMContext &C, unsigned Width) const {
|
||||
for (unsigned i = 0, e = (unsigned)LegalIntWidths.size(); i != e; ++i)
|
||||
if (Width <= LegalIntWidths[i])
|
||||
return Type::getIntNTy(C, LegalIntWidths[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
|
||||
ArrayRef<Value *> Indices) const {
|
||||
Type *Ty = ptrTy;
|
||||
|
Reference in New Issue
Block a user