mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-28 13:51:09 +00:00
Handle IntToPtr in isBytewiseValue
Summary: This helps with more efficient use of memset for pattern initialization From @pcc prototype for -ftrivial-auto-var-init=pattern optimizations Binary size change on CTMark, (with -fuse-ld=lld -Wl,--icf=all, similar results with default linker options) ``` master patch diff Os 8.238864e+05 8.238864e+05 0.0 O3 1.054797e+06 1.054797e+06 0.0 Os zero 8.292384e+05 8.292384e+05 0.0 O3 zero 1.062626e+06 1.062626e+06 0.0 Os pattern 8.579712e+05 8.338048e+05 -0.030299 O3 pattern 1.090502e+06 1.067574e+06 -0.020481 ``` Zero vs Pattern on master ``` zero pattern diff Os 8.292384e+05 8.579712e+05 0.036578 O3 1.062626e+06 1.090502e+06 0.025124 ``` Zero vs Pattern with the patch ``` zero pattern diff Os 8.292384e+05 8.338048e+05 0.003333 O3 1.062626e+06 1.067574e+06 0.003193 ``` Reviewers: pcc, eugenis Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63967 llvm-svn: 365858
This commit is contained in:
parent
965c4a8d02
commit
b875fd735d
@ -3218,6 +3218,17 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
|
||||
}
|
||||
}
|
||||
|
||||
if (auto *CE = dyn_cast<ConstantExpr>(C)) {
|
||||
if (CE->getOpcode() == Instruction::IntToPtr) {
|
||||
auto PS = DL.getPointerSizeInBits(
|
||||
cast<PointerType>(CE->getType())->getAddressSpace());
|
||||
return isBytewiseValue(
|
||||
ConstantExpr::getIntegerCast(CE->getOperand(0),
|
||||
Type::getIntNTy(Ctx, PS), false),
|
||||
DL);
|
||||
}
|
||||
}
|
||||
|
||||
auto Merge = [&](Value *LHS, Value *RHS) -> Value * {
|
||||
if (LHS == RHS)
|
||||
return LHS;
|
||||
|
@ -794,11 +794,11 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
|
||||
"i16* inttoptr (i64 0 to i16*)",
|
||||
},
|
||||
{
|
||||
"",
|
||||
"i8 -1",
|
||||
"i16* inttoptr (i64 -1 to i16*)",
|
||||
},
|
||||
{
|
||||
"",
|
||||
"i8 -86",
|
||||
"i16* inttoptr (i64 -6148914691236517206 to i16*)",
|
||||
},
|
||||
{
|
||||
@ -806,7 +806,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
|
||||
"i16* inttoptr (i48 -1 to i16*)",
|
||||
},
|
||||
{
|
||||
"",
|
||||
"i8 -1",
|
||||
"i16* inttoptr (i96 -1 to i16*)",
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user