Skip to content

Commit 68ff5f5

Browse files
committed
[aarch64] Fix vector FSUB subtracting the wrong registers
When intrinsics are not preferred, vector `FSUB` is lifted lane by lane. That lifting read `Vd` and `Vn` instead of `Vn` and `Vm`, so `fsub v0.4s, v1.4s, v2.4s` computed `v0 - v1`. It now computes `Vn - Vm`.
1 parent bcfaac2 commit 68ff5f5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎arch/arm64/il.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,15 +1805,16 @@ bool GetLowLevelILForInstruction(
18051805
if (preferIntrinsics())
18061806
return true;
18071807

1808-
Register srcs[16], dsts[16];
1808+
Register srcs1[16], srcs2[16], dsts[16];
18091809
int dst_n = unpack_vector(operand1, dsts);
1810-
int src_n = unpack_vector(operand2, srcs);
1811-
if ((dst_n != src_n) || dst_n == 0)
1810+
int src1_n = unpack_vector(operand2, srcs1);
1811+
int src2_n = unpack_vector(operand3, srcs2);
1812+
if ((dst_n != src1_n) || (src1_n != src2_n) || dst_n == 0)
18121813
ABORT_LIFT;
18131814

18141815
int rsize = RegisterSize(dsts[0]);
18151816
for (int i = 0; i < dst_n; ++i)
1816-
il.AddInstruction(ILSETREG(dsts[i], il.FloatSub(rsize, ILREG(dsts[i]), ILREG(srcs[i]))));
1817+
il.AddInstruction(ILSETREG(dsts[i], il.FloatSub(rsize, ILREG(srcs1[i]), ILREG(srcs2[i]))));
18171818
break;
18181819
}
18191820
default:

0 commit comments

Comments
 (0)