Skip to content

Commit 1638767

Browse files
committed
[AArch64] Sink mismatching wide extends to mul
If we have v4i64 mul(zext(v4i16), sext(v4i16)), we can code-generate that as v4i64 smull(v4i32 zext(v4i16), sext(v4i16), as zext(x)==sext(zext(x)). This teaches the part of CGP that sinks operands to uses about that, so that it can treat a zext that is more than twice the width as a sext.
1 parent ab9bdb7 commit 1638767

File tree

2 files changed

+144
-216
lines changed

2 files changed

+144
-216
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6649,10 +6649,15 @@ bool AArch64TTIImpl::isProfitableToSinkOperands(
66496649
Ops.push_back(&Ext->getOperandUse(0));
66506650
Ops.push_back(&Op);
66516651

6652-
if (isa<SExtInst>(Ext))
6652+
if (isa<SExtInst>(Ext)) {
66536653
NumSExts++;
6654-
else
6654+
} else {
66556655
NumZExts++;
6656+
// A zext(a) is also a sext(zext(a)), if we take more than 2 steps.
6657+
if (Ext->getOperand(0)->getType()->getScalarSizeInBits() * 2 <
6658+
I->getType()->getScalarSizeInBits())
6659+
NumSExts++;
6660+
}
66566661

66576662
continue;
66586663
}

0 commit comments

Comments
 (0)