<html 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=us-ascii">
<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;}
/* 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;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:11pt;color:#0078D7;margin:5pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal">Hi Arthur, </p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I was looking into porting the IR passes in to the NPM more than a year ago. Let me get back to you with more concrete answers.
</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Many thanks,<o:p></o:p></p>
<p class="MsoNormal">Reshabh<o:p></o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:llvm-dev@lists.llvm.org">Arthur Eubanks via llvm-dev</a><br>
<b>Sent: </b>Friday, January 8, 2021 1:58 AM<br>
<b>To: </b><a href="mailto:arsenm2@gmail.com">Matt Arsenault</a>; <a href="mailto:llvm-dev@lists.llvm.org">
llvm-dev</a>; <a href="mailto:nhaehnle@gmail.com">nhaehnle@gmail.com</a><br>
<b>Subject: </b>Re: [llvm-dev] AMDGPU and support for the new pass manager</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[CAUTION: External Email] <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">We're sorting out the custom inliner in <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD94153&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000259582%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wESrgfOchjmGwMu4wl553fTymdbPnvoasjcF%2B9Q%2Fpnk%3D&reserved=0">https://reviews.llvm.org/D94153</a>.
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">As for LegacyDivergenceAnalysis and Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll, if there's no response, I'll just pin the test to the legacy PM, since it's testing an AMDGPU-specific optimization setting (disabling loop unswitching
 on divergent loop conditions). If there are noticeable performance regressions related to this due to the NPM switch, the AMDGPU community can temporarily use the legacy PM and then port the relevant analysis passes and fix up loop unswitching for AMDGPU.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Then we should be good to go for turning on the new PM for opt when it's specified on the CMake command line.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Jan 4, 2021 at 2:16 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com">aeubanks@google.com</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">
<div>
<p class="MsoNormal">I've ported most of the IR passes and added them to AMDGPU's opt pipeline.
<o:p></o:p></p>
<div>
<p class="MsoNormal">There are 2 issues remaining:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1) LegacyDivergenceAnalysis is used in LoopUnswitch to avoid unswitching loops with divergent condition Values. I'm not sure what the state of the LegacyDivergenceAnalysis vs DivergenceAnalysis is. (Also the new PM only has SimpleLoopUnswitch
 instead of LoopUnswitch).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">2) The AMDGPU backend has its own <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2Fmain%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUInline.cpp&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000269575%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Y52BAjZbnZxzTYnMNpAzFh5A8GsC9AJcgxqR9xwYqT8%3D&reserved=0" target="_blank">
inliner</a> (set <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F92be640bd7d4fbc8e032a0aa81381a0246efa0be%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUTargetMachine.cpp%23L438&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000279572%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=AKsWY951zKzuz6YfLpbBEoywQQWh1SMqu38HbOPIX4I%3D&reserved=0" target="_blank">
here</a>). Any ideas for how to do custom inliner cost modeling in the new PM pipelines? Allow targets to override an analysis pass that the inliner uses to get an InlineAdvisor?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">CodeGen/AMDGPU/amdgpu-inline.ll<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Fri, Dec 4, 2020 at 4:44 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</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">
<div>
<p class="MsoNormal">Some indicative failing tests are under the llvm/test/CodeGen/AMDGPU directory when opt's -enable-new-pm flag is set to true by default. They should also be repro'able by adding a corresponding NPM RUN line, e.g. "opt -S -O1 -mtriple=amdgcn--
 ..." -> "opt -S -passes='default<O1>' -mtriple=amdgcn-- ...". <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I see the following AMDGPU-specific failures:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  LLVM :: CodeGen/AMDGPU/amdgpu-inline.ll<br>
  LLVM :: CodeGen/AMDGPU/infer-addrpace-pipeline.ll<br>
  LLVM :: CodeGen/AMDGPU/internalize.ll<br>
  LLVM :: CodeGen/AMDGPU/llvm.amdgcn.wavefrontsize.ll<br>
  LLVM :: CodeGen/AMDGPU/opt-pipeline.ll<br>
  LLVM :: CodeGen/AMDGPU/propagate-attributes-clone.ll<br>
  LLVM :: CodeGen/AMDGPU/propagate-attributes-single-set.ll<br>
  LLVM :: CodeGen/AMDGPU/simplify-libcalls.ll<br>
  LLVM :: CodeGen/AMDGPU/sroa-before-unroll.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  LLVM :: Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(Also I took a closer look, actually it looks like NVPTX also needs updating, but NVPTXTargetMachine only adds two passes)<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Fri, Dec 4, 2020 at 3:48 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</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">
<div>
<p class="MsoNormal">Currently AMDGPU is the last target which injects passes into the pipeline but hasn't been updated to work with the new pass manager.
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Recently there was added support for the NPM's equivalent of TargetMachine::adjustPassManager(). (<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.llvm.org%2Fshow_bug.cgi%3Fid%3D47244&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000279572%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=KrpH97uBBJkHUdP8vwCBE1N9Dfr7gcPvJ2sniJ%2F1byE%3D&reserved=0" target="_blank">Bug</a>,
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD88138&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000289565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lPG91RO7BATJFI8fkQ7XYSq5OavGhsUpjtRHT0uHwQ4%3D&reserved=0" target="_blank">
Phab</a>). <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7%2Fllvm%2Flib%2FTarget%2FBPF%2FBPFTargetMachine.cpp%23L126&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000289565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Uh3RM2sPGz7%2BFF5o3pG60CqRAchFbq%2FtsEbkjkS%2F1TU%3D&reserved=0" target="_blank">
BPF</a> and Hexagon have their NPM equivalents implemented already, but <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUTargetMachine.cpp%23L420&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000299565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zODbjrSVrFMHXrckrECafNIrmaNWLdjqtHlVOatUgwQ%3D&reserved=0" target="_blank">
AMDGPU has a lot of custom passes added by adjustPassManager</a> and hasn't been updated to work with the NPM.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal" style="margin-left:.2in">Could the maintainers of AMDGPU port the necessary passes to the new pass manager add them to AMDGPUTargetMachine::registerPassBuilderCallbacks()? I'm happy to provide any guidance if necessary.
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD91990&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000309558%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=M0WS7ZEG14yyfKghrwFkEgba6If7QsLnLZnjUIyIsgs%3D&reserved=0" target="_blank">
Here's</a> an example of porting a pass and adding it to the pipeline.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>