[PATCH] D36772: Unmerge GEPs to reduce register pressure on IndirectBr edges.
Hiroshi Yamauchi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 15:23:45 PDT 2017
yamauchi added inline comments.
================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:6264
+ UGEPI->setOperand(1, NewUGEPIIdx);
+ }
+ // After unmerging, verify that GEPIOp is actually only used in SrcBlock (not
----------------
hfinkel wrote:
> You'll also need to make sure that this GEP is not marked as inbounds if GEPI was not.
>
> if (!GEPI->isInBounds()) {
> UGEPI->setIsInBounds(false);
> }
>
> because otherwise the result of GEP could be not-in-bounds resulting in UB if that's used as the input to an inbounds UGEPI.
I'm not very familiar with how inbounds works.
Is an inbounds GEP UB if it takes a non-inbounds GEP as its operand (regardless of whether the index/offset is actually in bounds or not)?
For example,
Before:
%GEPIOp = ...
%GEPI = gep %GEPIOp 2
%UGEPI = gep inbounds %GEPIOp 1
After:
%GEPIOp = ...
%GEPI = gep %GEPIOp 2
%UGEPI = gep inbounds %GEPI -1
Suppose "gep %GEPIOp 2" is not in bounds and "gep inbounds %GEPIOp 1" is in bounds. Both aren't UB.
"gep inbounds %GEPI -1" is UB just because it takes (non-inbounds) "gep %GEPIOp 2" as an operand, even though the offset/index of "gep inbounds %GEPI -1" is actually in bounds?
https://reviews.llvm.org/D36772
More information about the llvm-commits
mailing list