Skip to content

Commit 4c3546f

Browse files
authored
[AArch64] Sink mismatching wide extends to mul (#164986)
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 b614767 commit 4c3546f

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
@@ -6657,10 +6657,15 @@ bool AArch64TTIImpl::isProfitableToSinkOperands(
66576657
Ops.push_back(&Ext->getOperandUse(0));
66586658
Ops.push_back(&Op);
66596659

6660-
if (isa<SExtInst>(Ext))
6660+
if (isa<SExtInst>(Ext)) {
66616661
NumSExts++;
6662-
else
6662+
} else {
66636663
NumZExts++;
6664+
// A zext(a) is also a sext(zext(a)), if we take more than 2 steps.
6665+
if (Ext->getOperand(0)->getType()->getScalarSizeInBits() * 2 <
6666+
I->getType()->getScalarSizeInBits())
6667+
NumSExts++;
6668+
}
66646669

66656670
continue;
66666671
}

0 commit comments

Comments
 (0)