diff options
author | David Sherwood <david.sherwood@arm.com> | 2020-07-02 12:24:45 +0100 |
---|---|---|
committer | David Sherwood <david.sherwood@arm.com> | 2020-07-08 09:16:00 +0100 |
commit | 15aeb805dc46fbd268388af5f8de19e4de29cdb3 (patch) | |
tree | c1f29aa87559146f009d2f25bb4a65594811b232 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 00580349c39280a1d0a9ef5999c9826dad553470 (diff) | |
download | llvm-15aeb805dc46fbd268388af5f8de19e4de29cdb3.zip llvm-15aeb805dc46fbd268388af5f8de19e4de29cdb3.tar.gz llvm-15aeb805dc46fbd268388af5f8de19e4de29cdb3.tar.bz2 |
[CodeGen] Fix warnings in sve-ld1-addressing-mode-reg-imm.ll
For the GetElementPtr case in function
AddressingModeMatcher::matchOperationAddr
I've changed the code to use the TypeSize class instead of relying
upon the implicit conversion to a uint64_t. As part of this we now
check for scalable types and if we encounter one just bail out for
now as the subsequent optimisations doesn't currently support them.
This changes fixes up all warnings in the following tests:
llvm/test/CodeGen/AArch64/sve-ld1-addressing-mode-reg-imm.ll
llvm/test/CodeGen/AArch64/sve-st1-addressing-mode-reg-imm.ll
Differential Revision: https://reviews.llvm.org/D83124
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 8181c66..5fe8a09 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -4356,15 +4356,20 @@ bool AddressingModeMatcher::matchOperationAddr(User *AddrInst, unsigned Opcode, cast<ConstantInt>(AddrInst->getOperand(i))->getZExtValue(); ConstantOffset += SL->getElementOffset(Idx); } else { - uint64_t TypeSize = DL.getTypeAllocSize(GTI.getIndexedType()); - if (ConstantInt *CI = dyn_cast<ConstantInt>(AddrInst->getOperand(i))) { - const APInt &CVal = CI->getValue(); - if (CVal.getMinSignedBits() <= 64) { - ConstantOffset += CVal.getSExtValue() * TypeSize; - continue; + TypeSize TS = DL.getTypeAllocSize(GTI.getIndexedType()); + if (TS.isNonZero()) { + // The optimisations below currently only work for fixed offsets. + if (TS.isScalable()) + return false; + int64_t TypeSize = TS.getFixedSize(); + if (ConstantInt *CI = + dyn_cast<ConstantInt>(AddrInst->getOperand(i))) { + const APInt &CVal = CI->getValue(); + if (CVal.getMinSignedBits() <= 64) { + ConstantOffset += CVal.getSExtValue() * TypeSize; + continue; + } } - } - if (TypeSize) { // Scales of zero don't do anything. // We only allow one variable index at the moment. if (VariableOperand != -1) return false; |