Skip to content

Commit 760ad23

Browse files
committed
[DAG] combineShiftToAVG - ensure the reduced demanded value type is smaller than the original.
Now we have promotion support we should be able to remove the next-power-of-2 code entirely, but this is good enough for now.
1 parent 04a09b9 commit 760ad23

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,8 @@ static SDValue combineShiftToAVG(SDValue Op,
10601060
unsigned MinWidth =
10611061
std::max<unsigned>(VT.getScalarSizeInBits() - KnownBits, 8);
10621062
EVT NVT = EVT::getIntegerVT(*DAG.getContext(), llvm::bit_ceil(MinWidth));
1063+
if (NVT.getScalarSizeInBits() > VT.getScalarSizeInBits())
1064+
return SDValue();
10631065
if (VT.isVector())
10641066
NVT = EVT::getVectorVT(*DAG.getContext(), NVT, VT.getVectorElementCount());
10651067
if (TLO.LegalOperations() && !TLI.isOperationLegal(AVGOpc, NVT)) {

llvm/test/CodeGen/AArch64/arm64-vhadd.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,10 +1395,8 @@ define <8 x i8> @sextmask3v8i8(<8 x i16> %src1, <8 x i8> %src2) {
13951395
define <4 x i16> @ext_via_i19(<4 x i16> %a) {
13961396
; CHECK-LABEL: ext_via_i19:
13971397
; CHECK: // %bb.0:
1398-
; CHECK-NEXT: movi.4s v1, #1
1399-
; CHECK-NEXT: uaddw.4s v0, v1, v0
1400-
; CHECK-NEXT: uhadd.4s v0, v0, v1
1401-
; CHECK-NEXT: xtn.4h v0, v0
1398+
; CHECK-NEXT: movi.4h v1, #1
1399+
; CHECK-NEXT: urhadd.4h v0, v0, v1
14021400
; CHECK-NEXT: ret
14031401
%t3 = zext <4 x i16> %a to <4 x i32>
14041402
%t4 = add <4 x i32> %t3, <i32 1, i32 1, i32 1, i32 1>

0 commit comments

Comments
 (0)