<font size=3 face="sans-serif">Hello,</font><br><br><font size=3 face="sans-serif">I’m looking at MachineLICM and running
into a limitation of not hoisting instructions that store a constant value
to a constant spot on the stack. I see this example in the case of indirect
calls for PowerPC. Indirect calls on PPC must be surrounded by instructions
that save and restore the TOC (similar to the GOT) pointer. This pointer
is in register X2 and will not change throughout the function.</font><br><br><font size=3 face="sans-serif">%vreg12<def> = COPY %X2; G8RC:%vreg12</font><br><font size=3 face="sans-serif">STD %vreg12, 24, %X1; mem:ST8[Stack+24]
G8RC:%vreg12</font><br><font size=3 face="sans-serif"> </font><br><font size=3 face="sans-serif">This currently can't be hoisted because:</font><br><font size=3 face="sans-serif">1. It is a store instruction</font><br><font size=3 face="sans-serif">2. It uses a physical register (the
stack pointer register - X1)</font><br><font size=3 face="sans-serif">3. The copy that defines the physical
register being stored isn't profitable to hoist</font><br><br><font size=3 face="sans-serif">As a proof of concept, I’ve relaxed
these conditions to catch these loop invariant stores by using the fact
that registers X1/X2 satisfy isCallerPreservedPhysReg(). With these relaxations
I get the following results in SPEC:</font><br><br><font size=3 face="sans-serif">Benchmark | Improvement | # of Hoists<br>dealII |0.10
% |1203</font><br><font size=3 face="sans-serif">h264ref |11 %
|347</font><br><font size=3 face="sans-serif">Gcc
|1.42 %
|135<br>xalancbmk |0.86 %
|3886</font><br><font size=3 face="sans-serif">Astar
| -2.39% |
1</font><br><br><font size=3 face="sans-serif">Astar here is an outlier where we see
a degradation. In this case, the store was hoisted out of an if statement
that is executed infrequently compared to the outer code. This results
in the store to r2 being executed more times dynamically.</font><br><font size=3 face="sans-serif"> </font><br><font size=3 face="sans-serif">I would like to add TargetInstrInfo
hooks like isInvariantStore(MachineInstr &) and isCopyFeedingInvariantStore(MachineInstr
&) that would tell MachineLICM that the two instructions are safe and
profitable to hoist. </font><br><br><font size=3 face="sans-serif">Please advise if adding the target hooks
is a good solution and if other targets would be interested in such hooks,
or whether I should be take a different approach.</font><br><font size=3 face="sans-serif"> </font><br><font size=3 face="sans-serif">Thanks,</font><br><font size=3 face="sans-serif">Zaara Syeda</font><BR>