Skip to content

Commit e79ed82

Browse files
authored
Partially revert "Combine cast => negate => compare on ARM64 #112944" (#118208)
1 parent ea076a5 commit e79ed82

File tree

2 files changed

+1
-93
lines changed

2 files changed

+1
-93
lines changed

src/coreclr/jit/lowerarmarch.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ bool Lowering::IsContainableUnaryOrBinaryOp(GenTree* parentNode, GenTree* childN
384384
if (childNode->OperIs(GT_NEG))
385385
{
386386
// If we have a contained LSH, RSH or RSZ, we can still contain NEG if the parent is a EQ or NE.
387-
if (childNode->gtGetOp1()->isContained() && !childNode->gtGetOp1()->OperIs(GT_LSH, GT_RSH, GT_RSZ, GT_CAST))
387+
if (childNode->gtGetOp1()->isContained() && !childNode->gtGetOp1()->OperIs(GT_LSH, GT_RSH, GT_RSZ))
388388
{
389389
// Cannot contain if the childs op1 is already contained
390390
return false;
@@ -403,31 +403,6 @@ bool Lowering::IsContainableUnaryOrBinaryOp(GenTree* parentNode, GenTree* childN
403403
{
404404
return false;
405405
}
406-
407-
if (childNode->gtGetOp1()->OperIs(GT_CAST))
408-
{
409-
// Grab the cast as well, we can contain this with cmn (extended-register).
410-
GenTreeCast* cast = childNode->gtGetOp1()->AsCast();
411-
GenTree* castOp = cast->CastOp();
412-
413-
// Cannot contain the cast from floating point.
414-
if (!varTypeIsIntegral(castOp))
415-
{
416-
return false;
417-
}
418-
419-
// Cannot contain the cast if it already contains it's CastOp.
420-
if (castOp->isContained())
421-
{
422-
return false;
423-
}
424-
425-
assert(!cast->gtOverflow());
426-
assert(varTypeIsIntegral(cast) && varTypeIsIntegral(cast->CastToType()));
427-
428-
MakeSrcContained(childNode, cast);
429-
}
430-
431406
return true;
432407
}
433408

src/tests/JIT/opt/InstructionCombining/Cmn.cs

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,6 @@ public static int CheckCompareNegative()
5050
fail = true;
5151
}
5252

53-
if (!CmnExtendedB(1, 0xff))
54-
{
55-
fail = true;
56-
}
57-
if (!CmnExtendedH(1, 0xffff))
58-
{
59-
fail = true;
60-
}
61-
if (!CmnExtendedS(1, 0xffffffff))
62-
{
63-
fail = true;
64-
}
65-
if (!CmnExtendedUB(-1, 0x101))
66-
{
67-
fail = true;
68-
}
69-
if (!CmnExtendedUH(-1, 0x10001))
70-
{
71-
fail = true;
72-
}
73-
if (!CmnExtendedUS(-1, 0x100000001))
74-
{
75-
fail = true;
76-
}
77-
7853
if (fail)
7954
{
8055
return 101;
@@ -159,47 +134,5 @@ static bool CmnLargeShift64Bit(long a, long b)
159134
}
160135
return false;
161136
}
162-
163-
[MethodImpl(MethodImplOptions.NoInlining)]
164-
static bool CmnExtendedB(int a, int b)
165-
{
166-
//ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, SXTB
167-
return (a == -(sbyte)b);
168-
}
169-
170-
[MethodImpl(MethodImplOptions.NoInlining)]
171-
static bool CmnExtendedH(int a, int b)
172-
{
173-
//ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, SXTH
174-
return (a == -(short)b);
175-
}
176-
177-
[MethodImpl(MethodImplOptions.NoInlining)]
178-
static bool CmnExtendedS(long a, long b)
179-
{
180-
//ARM64-FULL-LINE: cmn {{x[0-9]+}}, {{w[0-9]+}}, SXTW
181-
return (a == -(long)(int)b);
182-
}
183-
184-
[MethodImpl(MethodImplOptions.NoInlining)]
185-
static bool CmnExtendedUB(int a, int b)
186-
{
187-
//ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, UXTB
188-
return (a == -(byte)b);
189-
}
190-
191-
[MethodImpl(MethodImplOptions.NoInlining)]
192-
static bool CmnExtendedUH(int a, int b)
193-
{
194-
//ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, UXTH
195-
return (a == -(ushort)b);
196-
}
197-
198-
[MethodImpl(MethodImplOptions.NoInlining)]
199-
static bool CmnExtendedUS(long a, long b)
200-
{
201-
//ARM64-FULL-LINE: cmn {{x[0-9]+}}, {{w[0-9]+}}, UXTW
202-
return (a == -(uint)b);
203-
}
204137
}
205138
}

0 commit comments

Comments
 (0)