<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">We’re hitting the first one in this function (I’m trying to get a testcase that would reproduce this crash):<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">void DAGTypeLegalizer::SetWidenedVector(SDValue Op, SDValue Result) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  assert(Result.getValueType() ==<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">         TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">         "Invalid type for widened vector");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  AnalyzeNewValue(Result);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  auto &OpIdEntry = WidenedVectors[getTableId(Op)];<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  assert((OpIdEntry == 0) && "Node already widened!");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  OpIdEntry = getTableId(Result);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yes, v64i1 is legal, but it fails the condition ‘getTypeToTransformTo(v32i1) == v64i1’.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:Consolas">-- </span>
<span style="font-size:9.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Krzysztof Parzyszek 
<a href="mailto:kparzysz@quicinc.com"><span style="color:#0563C1">kparzysz@quicinc.com</span></a>   AI tools development<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Craig Topper <craig.topper@gmail.com> <br>
<b>Sent:</b> Monday, March 22, 2021 1:55 PM<br>
<b>To:</b> Krzysztof Parzyszek <kparzysz@quicinc.com><br>
<b>Cc:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [EXT] Re: [llvm-dev] SDAG: Type legalization woes (context insensitivity)<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Is v64i1 not a legal type for Hexagon? What assertion are you hitting?<o:p></o:p></p>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">~Craig<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Mar 22, 2021 at 11:30 AM Krzysztof Parzyszek via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Summary: some types need more contextual information to properly legalize than what TLI queries give.<br>
<br>
Example: consider v32i1:<br>
1.  v32i1 = compare v32i32, v32i32    ; all good<br>
2.  v32i1 = compare v32i16, v32i16    ; problem: v32i16 not legal, but v32i1 is<br>
<br>
  The type v32i1 is legal because there it can be represented in a register and can be a result of a legal comparison of legally-typed vectors.  But it can also be a result of comparing illegally-typed vectors, which causes a problem.<br>
  The type legalization first looks at the value type, sees v32i1, takes note that it's legal.  Then, for the second case, it will attempt to legalize the operand types, but that action would also cause the result type to change (e.g. widen everything: v32i16->v64i16,
 v32i1->v64i1), hitting an assertion.<br>
<br>
I'm seeing this issue on Hexagon, but it seems to be fairly generic in its nature.  Has anyone else experienced this?<br>
<br>
I want to fix this somehow.  My current idea is to simply allow a known legal type to be replaced with another legal type, but there may be different approaches, like using SDValue in the TLI.whatAbouThisType family.<br>
<br>
Does anybody have concerns, thoughts?<br>
<br>
--<br>
Krzysztof Parzyszek  <a href="mailto:kparzysz@quicinc.com" target="_blank">kparzysz@quicinc.com</a>   AI tools development<br>
<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" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>