[Hexagon] Performance regression with b2b
authorHarsha Jagasia <hjagasia@quicinc.com>
Fri, 2 Oct 2020 16:26:45 +0000 (11:26 -0500)
committerKrzysztof Parzyszek <kparzysz@quicinc.com>
Tue, 4 Jan 2022 22:09:47 +0000 (14:09 -0800)
commit2b1c6df5a60ab7846974676586b0e3801e919772
treea7bdee3a3965a11f54d36660d8bea23d22c43899
parentd5b6e30ed3acad794dd0aec400e617daffc6cc3d
[Hexagon] Performance regression with b2b

For code below:
        {
                r7 = addasl(r3,r0,#2)
                r8 = addasl(r3,r2,#2)
                r5 = memw(r3+r0<<#2)
                r6 = memw(r3+r2<<#2)
        }
        {
                p1 = cmp.gtu(r6,r5)
                if (p1.new) memw(r8+#0) = r5
                if (p1.new) memw(r7+#0) = r6
        }
        {
                r0 = mux(p1,r2,r4)

        }

In packetizer, a new packet is created for the cmp instruction since
there arent enough resources in previous packet. Also it is determined
that the cmp stalls by 2 cycles since it depends on the prior load of r5.
In current packetizer implementation, the predicated store is evaluated
for whether it can go in the same packet as compare, and since the compare
stalls, the stall of the predicated store does not matter and it can go in
the same packet as the cmp. However the predicated store will stall for
more cycles because of its dependence on the addasl instruction and to
avoid that stall we can put it in a new packet.

Improve the packetizer to check if an instruction being added to packet
will stall longer than instruction already in packet and if so create a
new packet.
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h
llvm/test/CodeGen/Hexagon/nbench1.ll [new file with mode: 0644]