<div dir="ltr">Your pattern says to try to do that impossible copy. When you have a COPY_TO_REGCLASS with different size registers, you end up getting some weirdness. You probably want something along these lines:<br><span style="font-family:monospace">diff --git a/llvm/lib/Target/PowerPC/PPCInstrSPE.td b/llvm/lib/Target/PowerPC/PPCInstrSPE.td<br>index 935c304..ec108b3 100644<br>--- a/llvm/lib/Target/PowerPC/PPCInstrSPE.td<br>+++ b/llvm/lib/Target/PowerPC/PPCInstrSPE.td<br>@@ -821,9 +821,9 @@ def SPESTWX : XForm_8<31, 151, (outs), (ins spe4rc:$rS, memrr:$dst),<br> <br> let Predicates = [HasSPE] in {<br> def : Pat<(f64 (extloadf32 iaddr:$src)),<br>- (COPY_TO_REGCLASS (SPELWZ iaddr:$src), SPERC)>;<br>+ (SUBREG_TO_REG (i64 1), (SPELWZ iaddr:$src), sub_32)>;<br> def : Pat<(f64 (extloadf32 xaddr:$src)),<br>- (COPY_TO_REGCLASS (SPELWZX xaddr:$src), SPERC)>;<br>+ (SUBREG_TO_REG (i64 1), (SPELWZX xaddr:$src), sub_32)>;<br> <br> def : Pat<(f64 (fpextend f32:$src)),<br></span><div><span style="font-family:monospace"> (COPY_TO_REGCLASS $src, SPERC)>;</span></div><div><br></div><div>That allows the test case to compile correctly but I haven't looked at the details of the produced code. You should have a look at all of your uses of COPY_TO_REGCLASS to see whether that is what you want or if it is a different output pattern you're after.</div><div><br></div><div>N<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 15, 2020 at 8:34 PM Justin Hibbits via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm trying to fix a bug in the PowerPC SPE backend that prevents a<br>
bunch of FreeBSD ports from building, including gtk20. The attached<br>
file, generated from the following C source, triggers the "Def ==<br>
PreviousDef" assertion in isNopCopy():<br>
<br>
typedef float a;<br>
typedef struct {<br>
a b, c;<br>
} complex;<br>
d(complex *e, complex *h) {<br>
double f = h->c, g = h->b;<br>
i(g);<br>
e->c = g * j(f);<br>
}<br>
<br>
This was a reduction from texlive's c_cos.c.<br>
<br>
The applicable assertion failure is:<br>
<br>
Assertion failed: (Def == PreviousDef), function isNopCopy, file<br>
/home/chmeee/llvm_git/llvm/llvm/lib/CodeGen/MachineCopyPropagation.cpp,<br>
line 338. PLEASE submit a bug report to <a href="https://bugs.llvm.org/" rel="noreferrer" target="_blank">https://bugs.llvm.org/</a> and<br>
include the crash backtrace. Stack dump:<br>
0. Program arguments: /ralga/scratch/chmeee/builds/llvm/bin/llc<br>
-mtriple powerpcspe reduced.ll <br>
1. Running pass 'Function Pass Manager' on module 'reduced.ll'. <br>
2. Running pass 'Machine Copy Propagation Pass' on function '@d'<br>
<br>
<br>
I dumped the debug during this, and found the following interesting<br>
bits:<br>
<br>
0B bb.0.entry:<br>
liveins: $r4<br>
16B %1:gprc_and_gprc_nor0 = COPY $r4<br>
32B %2:gprc = SPELWZ 0, undef %3:gprc_and_gprc_nor0 :: (load 4<br>
from `float* undef`) 40B %5:gprc = SPELWZ 0, killed<br>
%1:gprc_and_gprc_nor0 :: (load 4 from %ir.b1) 48B %4:sperc = COPY<br>
killed %2:gprc 80B %6:sperc = COPY killed %5:gprc<br>
<br>
...<br>
MCP: Copy is a deletion candidate: renamable $s29 = COPY killed<br>
renamable $r4<br>
MCP: Copy is used - not dead: renamable $s29 = COPY<br>
killed renamable $r4 <br>
MCP: Copy is used - not dead: renamable $s29 = COPY killed renamable<br>
$r4<br>
<br>
$s29 is a SPE register (64-bits wide), while $r4 is a GPR (32-bits<br>
wide), and given what I've found googling this assert, the assert<br>
indicates two different register classes, which is obvious from this.<br>
The question is *where* and *why* do I have this?<br>
<br>
At first I thought to look through PPCFastISel.cpp, since there's some<br>
code in there that does fast selection with assumptions of the<br>
traditional PowerPC FPU. However, that didn't pan out. Now I'm<br>
scratching my head, and looking for help on where to try next, as every<br>
place I've found "TargetOpcode::COPY" and "PPC::COPY" appear to be<br>
covered already, correctly.<br>
<br>
Thanks,<br>
Justin<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>