[PATCH] D90131: [PowerPC] Add folding patterns for rlwinm + andi_rec.

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 21 14:07:33 PST 2020


nemanjai added inline comments.


================
Comment at: llvm/test/CodeGen/PowerPC/p10-spill-crlt.ll:78
+; CHECK-NEXT:    rlwinm. r3, r30, 0, 30, 30
+; CHECK-NEXT:    rlwinm r29, r30, 0, 24, 22
 ; CHECK-NEXT:    mcrf cr2, cr0
----------------
Esme wrote:
> nemanjai wrote:
> > nemanjai wrote:
> > > Well this is less than ideal. Perhaps we should only do this if the GPR that the `andi.` defines is dead?
> > Sorry, this was meant to say that we should check that the GPR that `andi.` **uses** is killed.
> > Sorry, this was meant to say that we should check that the GPR that `andi.` **uses** is killed.
> 
> @nemanjai Sorry, although I have updated the revision, I am actually a bit confused about this fix. As the comment added in last version (Diff 308919), I assumed the deg was caused by RA. 
> ```
> ; FIXME: A redundant COPY was generated during RA.
> ; i.e.   rlwinm r29, r30, 0, 24, 22
> ;        mr r30, r29
> ```
> Checking the GPR that andi. uses is killed can skip folding the case and avoid the deg, however is it the cause of the deg? I would be thankful if you have more comments about this issue.
Well, prior to this change, you had:
```
0x0: rlwinm r30, r30, 0, 24, 22
0x4: andi. r3, r30, 2
...
# some subsequent use of r30
```
So when you change it to an `rlwinm.` that produces what `andi.` produces, you no longer have the value that was previously produced by the existing `rlwinm` (on `0x0` above). Therefore, that instruction has to be kept so you get `rlwinm r29, r30, 0, 24, 22`.
But then you might wonder why doesn't it just end up being `rlwinm r30, r30, 0, 24, 22`? I suspect that is because the input register is still not marked as killed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90131/new/

https://reviews.llvm.org/D90131



More information about the llvm-commits mailing list