<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 9, 2020 at 3:50 AM Roman Lebedev <<a href="mailto:lebedev.ri@gmail.com">lebedev.ri@gmail.com</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">On Wed, Sep 9, 2020 at 6:19 AM Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>> wrote:<br>
><br>
> Hi Roman,<br>
Hi.<br>
<br>
> This seems like a pretty good idea,<br>
<br>
> but the change to EarlyCSE seems to be necessary before disabling a bunch of optimization?<br>
> Or am I misreading the comment in the commit?<br>
I really don't see what you mean.<br>
Nothing in that commit message talks about the need for an EarlyCSE change,<br>
or about "disabling a bunch of optimization". What it does talk about,<br>
is that we may want an InstCombine-based PHI CSE, and we got that<br>
in <a href="https://reviews.llvm.org/rGbf21ce7b908e16db76f5704714ee83e61a9da95b" rel="noreferrer" target="_blank">https://reviews.llvm.org/rGbf21ce7b908e16db76f5704714ee83e61a9da95b</a><br>
<br>
> I've managed to find a couple of regressions in tcmalloc with this and was wondering if you'd seen performance or just compile time improvements?<br>
Note this patch isn't a standalone "let's have less `extractvalue`e",<br>
but it belongs to the series of folds designed to ensure that as many<br>
`invoke`s as possible are no longer `invoke`s, but are converted into `call`s,<br>
which, i think you'll agree, generally allows much more optimizations.<br>
<br></blockquote><div><br></div><div>Agreed, but only if you have invokes :) Most of my code is compiled with -fno-exceptions.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
That end goal is almost a correctness thing, while the patch is just<br>
an exploratory step. As i've since established with certainty<br>
(<a href="https://reviews.llvm.org/D86530#2247674" rel="noreferrer" target="_blank">https://reviews.llvm.org/D86530#2247674</a>), i'll need a more<br>
general approach, so *in principle* this particular<br>
change could go away afterwards.<br>
<br>
But no, i haven't observed any notable (above the noiselevel)<br>
performance changes in this patch.<br>
<br></blockquote><div><br></div><div>OK.  It was this set of comments that concerned me:</div><div><br></div><div>>> 1. After this fold, as it can be seen in tests, we may (will) end up with trivially redundant PHI nodes.<br>
>>    We don't CSE them in InstCombine presently, which means that EarlyCSE needs to run and then InstCombine rerun.<br>
>> 2. But then, EarlyCSE not only manages to fold such redundant PHI's,<br>
>>    it also sees that the extract-insert chain recreates the original aggregate,<br>
>>    and replaces it with the original aggregate.<br></div><div><br></div><div>I am seeing some performance regressions, but I'll investigate and see if I can't get some program counters and a bit more here for you.</div><div><br></div><div>Thanks!</div><div><br></div><div>-eric</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> -eric<br>
<br>
<br>
Roman<br>
<br>
> On Wed, Aug 26, 2020 at 2:58 AM Roman Lebedev via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>><br>
>> Author: Roman Lebedev<br>
>> Date: 2020-08-26T09:57:50+03:00<br>
>> New Revision: 1f90d45b9eb4550a4143ad846e2623fc1b7c05ab<br>
>><br>
>> URL: <a href="https://github.com/llvm/llvm-project/commit/1f90d45b9eb4550a4143ad846e2623fc1b7c05ab" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1f90d45b9eb4550a4143ad846e2623fc1b7c05ab</a><br>
>> DIFF: <a href="https://github.com/llvm/llvm-project/commit/1f90d45b9eb4550a4143ad846e2623fc1b7c05ab.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1f90d45b9eb4550a4143ad846e2623fc1b7c05ab.diff</a><br>
>><br>
>> LOG: [InstCombine] PHI-of-extractvalues -> extractvalue-of-PHI, aka invokes are bad<br>
>><br>
>> While since D86306 we do it's sibling fold for `insertvalue`,<br>
>> we should also do this for `extractvalue`'s.<br>
>><br>
>> And unlike that one, the results here are, quite honestly, shocking,<br>
>> as it can be observed here on vanilla llvm test-suite + RawSpeed results:<br>
>><br>
>> ```<br>
>> | statistic name                                     | baseline  | proposed  |       Δ |       % |    |%| |<br>
>> |----------------------------------------------------|-----------|-----------|--------:|--------:|-------:|<br>
>> | asm-printer.EmittedInsts                           | 7945095   | 7942507   |   -2588 |  -0.03% |  0.03% |<br>
>> | assembler.ObjectBytes                              | 273209920 | 273069800 | -140120 |  -0.05% |  0.05% |<br>
>> | early-cse.NumCSE                                   | 2183363   | 2183398   |      35 |   0.00% |  0.00% |<br>
>> | early-cse.NumSimplify                              | 541847    | 550017    |    8170 |   1.51% |  1.51% |<br>
>> | instcombine.NumAggregateReconstructionsSimplified  | 2139      | 108       |   -2031 | -94.95% | 94.95% |<br>
>> | instcombine.NumCombined                            | 3601364   | 3635448   |   34084 |   0.95% |  0.95% |<br>
>> | instcombine.NumConstProp                           | 27153     | 27157     |       4 |   0.01% |  0.01% |<br>
>> | instcombine.NumDeadInst                            | 1694521   | 1765022   |   70501 |   4.16% |  4.16% |<br>
>> | instcombine.NumPHIsOfExtractValues                 | 0         | 37546     |   37546 |   0.00% |  0.00% |<br>
>> | instcombine.NumSunkInst                            | 63158     | 63686     |     528 |   0.84% |  0.84% |<br>
>> | instcount.NumBrInst                                | 874304    | 871857    |   -2447 |  -0.28% |  0.28% |<br>
>> | instcount.NumCallInst                              | 1757657   | 1758402   |     745 |   0.04% |  0.04% |<br>
>> | instcount.NumExtractValueInst                      | 45623     | 11483     |  -34140 | -74.83% | 74.83% |<br>
>> | instcount.NumInsertValueInst                       | 4983      | 580       |   -4403 | -88.36% | 88.36% |<br>
>> | instcount.NumInvokeInst                            | 61018     | 59478     |   -1540 |  -2.52% |  2.52% |<br>
>> | instcount.NumLandingPadInst                        | 35334     | 34215     |   -1119 |  -3.17% |  3.17% |<br>
>> | instcount.NumPHIInst                               | 344428    | 331116    |  -13312 |  -3.86% |  3.86% |<br>
>> | instcount.NumRetInst                               | 100773    | 100772    |      -1 |   0.00% |  0.00% |<br>
>> | instcount.TotalBlocks                              | 1081154   | 1077166   |   -3988 |  -0.37% |  0.37% |<br>
>> | instcount.TotalFuncs                               | 101443    | 101442    |      -1 |   0.00% |  0.00% |<br>
>> | instcount.TotalInsts                               | 8890201   | 8833747   |  -56454 |  -0.64% |  0.64% |<br>
>> | instsimplify.NumSimplified                         | 75822     | 75707     |    -115 |  -0.15% |  0.15% |<br>
>> | simplifycfg.NumHoistCommonCode                     | 24203     | 24197     |      -6 |  -0.02% |  0.02% |<br>
>> | simplifycfg.NumHoistCommonInstrs                   | 48201     | 48195     |      -6 |  -0.01% |  0.01% |<br>
>> | simplifycfg.NumInvokes                             | 2785      | 4298      |    1513 |  54.33% | 54.33% |<br>
>> | simplifycfg.NumSimpl                               | 997332    | 1018189   |   20857 |   2.09% |  2.09% |<br>
>> | simplifycfg.NumSinkCommonCode                      | 7088      | 6464      |    -624 |  -8.80% |  8.80% |<br>
>> | simplifycfg.NumSinkCommonInstrs                    | 15117     | 14021     |   -1096 |  -7.25% |  7.25% |<br>
>> ```<br>
>> ... which tells us that this new fold fires whopping 38k times,<br>
>> increasing the amount of SimplifyCFG's `invoke`->`call` transforms by +54% (+1513) (again, D85787 did that last time),<br>
>> decreasing total instruction count by -0.64% (-56454),<br>
>> and sharply decreasing count of `insertvalue`'s (-88.36%, i.e. 9 times less)<br>
>> and `extractvalue`'s (-74.83%, i.e. four times less).<br>
>><br>
>> This causes geomean -0.01% binary size decrease<br>
>> <a href="http://llvm-compile-time-tracker.com/compare.php?from=4d5ca22b8adfb6643466e4e9f48ba14bb48938bc&to=97dacca0111cb2ae678204e52a3cee00e3a69208&stat=size-text" rel="noreferrer" target="_blank">http://llvm-compile-time-tracker.com/compare.php?from=4d5ca22b8adfb6643466e4e9f48ba14bb48938bc&to=97dacca0111cb2ae678204e52a3cee00e3a69208&stat=size-text</a><br>
>> and, ignoring `O0-g`, is a geomean -0.01%..-0.05% compile-time improvement<br>
>> <a href="http://llvm-compile-time-tracker.com/compare.php?from=4d5ca22b8adfb6643466e4e9f48ba14bb48938bc&to=97dacca0111cb2ae678204e52a3cee00e3a69208&stat=instructions" rel="noreferrer" target="_blank">http://llvm-compile-time-tracker.com/compare.php?from=4d5ca22b8adfb6643466e4e9f48ba14bb48938bc&to=97dacca0111cb2ae678204e52a3cee00e3a69208&stat=instructions</a><br>
>><br>
>> The other thing that tells is, is that while this is a massive win for `invoke`->`call` transform<br>
>> `InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse()` fold,<br>
>> which is supposed to be dealing with such aggregate reconstructions,<br>
>> fires a lot less now. There are two reasons why:<br>
>> 1. After this fold, as it can be seen in tests, we may (will) end up with trivially redundant PHI nodes.<br>
>>    We don't CSE them in InstCombine presently, which means that EarlyCSE needs to run and then InstCombine rerun.<br>
>> 2. But then, EarlyCSE not only manages to fold such redundant PHI's,<br>
>>    it also sees that the extract-insert chain recreates the original aggregate,<br>
>>    and replaces it with the original aggregate.<br>
>><br>
>> The take-aways are<br>
>> 1. We maybe should do most trivial, same-BB PHI CSE in InstCombine<br>
>> 2. I need to check if what other patterns remain, and how they can be resolved.<br>
>>    (i.e. i wonder if `foldAggregateConstructionIntoAggregateReuse()` might go away)<br>
>><br>
>> This is a reland of the original commit fcb51d8c2460faa23b71e06abb7e826243887dd6,<br>
>> because originally i forgot to ensure that the base aggregate types match.<br>
>><br>
>> Reviewed By: spatel<br>
>><br>
>> Differential Revision: <a href="https://reviews.llvm.org/D86530" rel="noreferrer" target="_blank">https://reviews.llvm.org/D86530</a><br>
>><br>
>> Added:<br>
>><br>
>><br>
>> Modified:<br>
>>     llvm/lib/Transforms/InstCombine/InstCombineInternal.h<br>
>>     llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp<br>
>>     llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll<br>
>>     llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll<br>
>><br>
>> Removed:<br>
>><br>
>><br>
>><br>
>> ################################################################################<br>
>> diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h<br>
>> index e5fe99367b7b..86b0bfe24d28 100644<br>
>> --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h<br>
>> +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h<br>
>> @@ -618,6 +618,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final<br>
>>    Instruction *foldPHIArgOpIntoPHI(PHINode &PN);<br>
>>    Instruction *foldPHIArgBinOpIntoPHI(PHINode &PN);<br>
>>    Instruction *foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN);<br>
>> +  Instruction *foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN);<br>
>>    Instruction *foldPHIArgGEPIntoPHI(PHINode &PN);<br>
>>    Instruction *foldPHIArgLoadIntoPHI(PHINode &PN);<br>
>>    Instruction *foldPHIArgZextsIntoPHI(PHINode &PN);<br>
>><br>
>> diff  --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp<br>
>> index 269b4d550e43..4c43e835186a 100644<br>
>> --- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp<br>
>> +++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp<br>
>> @@ -32,6 +32,8 @@ MaxNumPhis("instcombine-max-num-phis", cl::init(512),<br>
>><br>
>>  STATISTIC(NumPHIsOfInsertValues,<br>
>>            "Number of phi-of-insertvalue turned into insertvalue-of-phis");<br>
>> +STATISTIC(NumPHIsOfExtractValues,<br>
>> +          "Number of phi-of-extractvalue turned into extractvalue-of-phi");<br>
>><br>
>>  /// The PHI arguments will be folded into a single operation with a PHI node<br>
>>  /// as input. The debug location of the single operation will be the merged<br>
>> @@ -336,6 +338,43 @@ InstCombinerImpl::foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN) {<br>
>>    return NewIVI;<br>
>>  }<br>
>><br>
>> +/// If we have something like phi [extractvalue(a,0), extractvalue(b,0)],<br>
>> +/// turn this into a phi[a,b] and a single extractvalue.<br>
>> +Instruction *<br>
>> +InstCombinerImpl::foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN) {<br>
>> +  auto *FirstEVI = cast<ExtractValueInst>(PN.getIncomingValue(0));<br>
>> +<br>
>> +  // Scan to see if all operands are `extractvalue`'s with the same indicies,<br>
>> +  // and all have a single use.<br>
>> +  for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {<br>
>> +    auto *I = dyn_cast<ExtractValueInst>(PN.getIncomingValue(i));<br>
>> +    if (!I || !I->hasOneUse() || I->getIndices() != FirstEVI->getIndices() ||<br>
>> +        I->getAggregateOperand()->getType() !=<br>
>> +            FirstEVI->getAggregateOperand()->getType())<br>
>> +      return nullptr;<br>
>> +  }<br>
>> +<br>
>> +  // Create a new PHI node to receive the values the aggregate operand has<br>
>> +  // in each incoming basic block.<br>
>> +  auto *NewAggregateOperand = PHINode::Create(<br>
>> +      FirstEVI->getAggregateOperand()->getType(), PN.getNumIncomingValues(),<br>
>> +      FirstEVI->getAggregateOperand()->getName() + ".pn");<br>
>> +  // And populate the PHI with said values.<br>
>> +  for (auto Incoming : zip(PN.blocks(), PN.incoming_values()))<br>
>> +    NewAggregateOperand->addIncoming(<br>
>> +        cast<ExtractValueInst>(std::get<1>(Incoming))->getAggregateOperand(),<br>
>> +        std::get<0>(Incoming));<br>
>> +  InsertNewInstBefore(NewAggregateOperand, PN);<br>
>> +<br>
>> +  // And finally, create `extractvalue` over the newly-formed PHI nodes.<br>
>> +  auto *NewEVI = ExtractValueInst::Create(NewAggregateOperand,<br>
>> +                                          FirstEVI->getIndices(), PN.getName());<br>
>> +<br>
>> +  PHIArgMergedDebugLoc(NewEVI, PN);<br>
>> +  ++NumPHIsOfExtractValues;<br>
>> +  return NewEVI;<br>
>> +}<br>
>> +<br>
>>  /// If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the<br>
>>  /// adds all have a single use, turn this into a phi and a single binop.<br>
>>  Instruction *InstCombinerImpl::foldPHIArgBinOpIntoPHI(PHINode &PN) {<br>
>> @@ -788,6 +827,8 @@ Instruction *InstCombinerImpl::foldPHIArgOpIntoPHI(PHINode &PN) {<br>
>>      return foldPHIArgLoadIntoPHI(PN);<br>
>>    if (isa<InsertValueInst>(FirstInst))<br>
>>      return foldPHIArgInsertValueInstructionIntoPHI(PN);<br>
>> +  if (isa<ExtractValueInst>(FirstInst))<br>
>> +    return foldPHIArgExtractValueInstructionIntoPHI(PN);<br>
>><br>
>>    // Scan the instruction, looking for input operations that can be folded away.<br>
>>    // If all input operands to the phi are the same instruction (e.g. a cast from<br>
>><br>
>> diff  --git a/llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll b/llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll<br>
>> index b97b40827ccd..939126bd2e34 100644<br>
>> --- a/llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll<br>
>> +++ b/llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll<br>
>> @@ -24,9 +24,14 @@ define { i32, i32 } @test0({ i32, i32 } %agg_left, { i32, i32 } %agg_right, i1 %<br>
>>  ; CHECK-NEXT:    call void @bar()<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[I8_MERGED:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN1:%.*]] = phi { i32, i32 } [ [[AGG_LEFT]], [[LEFT]] ], [ [[AGG_RIGHT]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[I6:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN1]], 1<br>
>> +; CHECK-NEXT:    [[I5:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>> -; CHECK-NEXT:    ret { i32, i32 } [[I8_MERGED]]<br>
>> +; CHECK-NEXT:    [[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0<br>
>> +; CHECK-NEXT:    [[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1<br>
>> +; CHECK-NEXT:    ret { i32, i32 } [[I8]]<br>
>>  ;<br>
>>  entry:<br>
>>    br i1 %c, label %left, label %right<br>
>> @@ -58,18 +63,16 @@ define { i32, i32 } @negative_test1({ i32, i32 } %agg_left, { i32, i32 } %agg_ri<br>
>>  ; CHECK-NEXT:  entry:<br>
>>  ; CHECK-NEXT:    br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]<br>
>>  ; CHECK:       left:<br>
>> -; CHECK-NEXT:    [[I4:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 1<br>
>> -; CHECK-NEXT:    [[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0<br>
>>  ; CHECK-NEXT:    call void @foo()<br>
>>  ; CHECK-NEXT:    br label [[END:%.*]]<br>
>>  ; CHECK:       right:<br>
>> -; CHECK-NEXT:    [[I3:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT]], 0<br>
>> -; CHECK-NEXT:    [[I2:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT]], 1<br>
>>  ; CHECK-NEXT:    call void @bar()<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[I5:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I3]], [[RIGHT]] ]<br>
>> -; CHECK-NEXT:    [[I6:%.*]] = phi i32 [ [[I4]], [[LEFT]] ], [ [[I2]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_RIGHT_PN:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT]], [[LEFT]] ], [ [[AGG_LEFT]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[I6:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT_PN]], 1<br>
>> +; CHECK-NEXT:    [[I5:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>>  ; CHECK-NEXT:    [[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0<br>
>>  ; CHECK-NEXT:    [[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1<br>
>> @@ -154,24 +157,20 @@ define { i32, i32 } @test3({ i32, i32 } %agg_00, { i32, i32 } %agg_01, { i32, i3<br>
>>  ; CHECK:       bb0.dispatch:<br>
>>  ; CHECK-NEXT:    br i1 [[C1:%.*]], label [[BB00:%.*]], label [[BB01:%.*]]<br>
>>  ; CHECK:       bb00:<br>
>> -; CHECK-NEXT:    [[I0:%.*]] = extractvalue { i32, i32 } [[AGG_00:%.*]], 0<br>
>> -; CHECK-NEXT:    [[I1:%.*]] = extractvalue { i32, i32 } [[AGG_00]], 1<br>
>>  ; CHECK-NEXT:    br label [[BB0_MERGE:%.*]]<br>
>>  ; CHECK:       bb01:<br>
>> -; CHECK-NEXT:    [[I2:%.*]] = extractvalue { i32, i32 } [[AGG_01:%.*]], 0<br>
>> -; CHECK-NEXT:    [[I3:%.*]] = extractvalue { i32, i32 } [[AGG_01]], 1<br>
>>  ; CHECK-NEXT:    br label [[BB0_MERGE]]<br>
>>  ; CHECK:       bb0.merge:<br>
>> -; CHECK-NEXT:    [[I4:%.*]] = phi i32 [ [[I0]], [[BB00]] ], [ [[I2]], [[BB01]] ]<br>
>> -; CHECK-NEXT:    [[I5:%.*]] = phi i32 [ [[I1]], [[BB00]] ], [ [[I3]], [[BB01]] ]<br>
>> +; CHECK-NEXT:    [[AGG_00_PN:%.*]] = phi { i32, i32 } [ [[AGG_00:%.*]], [[BB00]] ], [ [[AGG_01:%.*]], [[BB01]] ]<br>
>> +; CHECK-NEXT:    [[AGG_00_PN1:%.*]] = phi { i32, i32 } [ [[AGG_00]], [[BB00]] ], [ [[AGG_01]], [[BB01]] ]<br>
>>  ; CHECK-NEXT:    br label [[END:%.*]]<br>
>>  ; CHECK:       bb10:<br>
>> -; CHECK-NEXT:    [[I6:%.*]] = extractvalue { i32, i32 } [[AGG_10:%.*]], 0<br>
>> -; CHECK-NEXT:    [[I7:%.*]] = extractvalue { i32, i32 } [[AGG_10]], 1<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[I8:%.*]] = phi i32 [ [[I4]], [[BB0_MERGE]] ], [ [[I6]], [[BB10]] ]<br>
>> -; CHECK-NEXT:    [[I9:%.*]] = phi i32 [ [[I5]], [[BB0_MERGE]] ], [ [[I7]], [[BB10]] ]<br>
>> +; CHECK-NEXT:    [[AGG_00_PN_PN:%.*]] = phi { i32, i32 } [ [[AGG_00_PN]], [[BB0_MERGE]] ], [ [[AGG_10:%.*]], [[BB10]] ]<br>
>> +; CHECK-NEXT:    [[AGG_00_PN1_PN:%.*]] = phi { i32, i32 } [ [[AGG_00_PN1]], [[BB0_MERGE]] ], [ [[AGG_10]], [[BB10]] ]<br>
>> +; CHECK-NEXT:    [[I9:%.*]] = extractvalue { i32, i32 } [[AGG_00_PN1_PN]], 1<br>
>> +; CHECK-NEXT:    [[I8:%.*]] = extractvalue { i32, i32 } [[AGG_00_PN_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>>  ; CHECK-NEXT:    [[I10:%.*]] = insertvalue { i32, i32 } undef, i32 [[I8]], 0<br>
>>  ; CHECK-NEXT:    [[I11:%.*]] = insertvalue { i32, i32 } [[I10]], i32 [[I9]], 1<br>
>> @@ -278,12 +277,17 @@ define { i32, i32 } @test5({ i32, i32 } %agg_left, { i32, i32 } %agg_right, i1 %<br>
>>  ; CHECK-NEXT:    call void @bar()<br>
>>  ; CHECK-NEXT:    br label [[MIDDLE]]<br>
>>  ; CHECK:       middle:<br>
>> -; CHECK-NEXT:    [[I8_MERGED:%.*]] = phi { i32, i32 } [ [[I8_MERGED]], [[MIDDLE]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[I8:%.*]], [[MIDDLE]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN1:%.*]] = phi { i32, i32 } [ [[AGG_LEFT]], [[LEFT]] ], [ [[AGG_RIGHT]], [[RIGHT]] ], [ [[I8]], [[MIDDLE]] ]<br>
>> +; CHECK-NEXT:    [[I6:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN1]], 1<br>
>> +; CHECK-NEXT:    [[I5:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>> +; CHECK-NEXT:    [[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0<br>
>> +; CHECK-NEXT:    [[I8]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1<br>
>>  ; CHECK-NEXT:    [[C1:%.*]] = call i1 @geni1()<br>
>>  ; CHECK-NEXT:    br i1 [[C1]], label [[END:%.*]], label [[MIDDLE]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    ret { i32, i32 } [[I8_MERGED]]<br>
>> +; CHECK-NEXT:    ret { i32, i32 } [[I8]]<br>
>>  ;<br>
>>  entry:<br>
>>    br i1 %c0, label %left, label %right<br>
>> @@ -327,15 +331,20 @@ define { i32, i32 } @test6({ i32, i32 } %agg_left, { i32, i32 } %agg_right, i1 %<br>
>>  ; CHECK-NEXT:    call void @bar()<br>
>>  ; CHECK-NEXT:    br label [[MERGE]]<br>
>>  ; CHECK:       merge:<br>
>> -; CHECK-NEXT:    [[I8_MERGED:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN1:%.*]] = phi { i32, i32 } [ [[AGG_LEFT]], [[LEFT]] ], [ [[AGG_RIGHT]], [[RIGHT]] ]<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>>  ; CHECK-NEXT:    br i1 [[C1:%.*]], label [[END:%.*]], label [[PASSTHROUGH:%.*]]<br>
>>  ; CHECK:       passthrough:<br>
>>  ; CHECK-NEXT:    call void @qux()<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> +; CHECK-NEXT:    [[I6:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN1]], 1<br>
>> +; CHECK-NEXT:    [[I5:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @quux()<br>
>> -; CHECK-NEXT:    ret { i32, i32 } [[I8_MERGED]]<br>
>> +; CHECK-NEXT:    [[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0<br>
>> +; CHECK-NEXT:    [[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1<br>
>> +; CHECK-NEXT:    ret { i32, i32 } [[I8]]<br>
>>  ;<br>
>>  entry:<br>
>>    br i1 %c0, label %left, label %right<br>
>> @@ -490,9 +499,14 @@ define { i32, i32 } @test9({ i32, i32 } %agg_left, { i32, i32 } %agg_right, i1 %<br>
>>  ; CHECK-NEXT:    call void @bar()<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[I8_MERGED:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN1:%.*]] = phi { i32, i32 } [ [[AGG_LEFT]], [[LEFT]] ], [ [[AGG_RIGHT]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[I7:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN1]], 1<br>
>> +; CHECK-NEXT:    [[I0_PN:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>> +; CHECK-NEXT:    [[I6:%.*]] = insertvalue { i32, i32 } undef, i32 [[I0_PN]], 0<br>
>>  ; CHECK-NEXT:    call void @baz()<br>
>> -; CHECK-NEXT:    ret { i32, i32 } [[I8_MERGED]]<br>
>> +; CHECK-NEXT:    [[I8:%.*]] = insertvalue { i32, i32 } [[I6]], i32 [[I7]], 1<br>
>> +; CHECK-NEXT:    ret { i32, i32 } [[I8]]<br>
>>  ;<br>
>>  entry:<br>
>>    br i1 %c, label %left, label %right<br>
>><br>
>> diff  --git a/llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll b/llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll<br>
>> index 78ea09f7e636..46cbd123f5fb 100644<br>
>> --- a/llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll<br>
>> +++ b/llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll<br>
>> @@ -10,13 +10,12 @@ define i32 @test0({ i32, i32 } %agg_left, { i32, i32 } %agg_right, i1 %c) {<br>
>>  ; CHECK-NEXT:  entry:<br>
>>  ; CHECK-NEXT:    br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]<br>
>>  ; CHECK:       left:<br>
>> -; CHECK-NEXT:    [[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0<br>
>>  ; CHECK-NEXT:    br label [[END:%.*]]<br>
>>  ; CHECK:       right:<br>
>> -; CHECK-NEXT:    [[I1:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 0<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[R:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I1]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { i32, i32 } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[R:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT_PN]], 0<br>
>>  ; CHECK-NEXT:    ret i32 [[R]]<br>
>>  ;<br>
>>  entry:<br>
>> @@ -169,13 +168,12 @@ define i32 @test5({{ i32, i32 }, { i32, i32 }} %agg_left, {{ i32, i32 }, { i32,<br>
>>  ; CHECK-NEXT:  entry:<br>
>>  ; CHECK-NEXT:    br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]<br>
>>  ; CHECK:       left:<br>
>> -; CHECK-NEXT:    [[I0:%.*]] = extractvalue { { i32, i32 }, { i32, i32 } } [[AGG_LEFT:%.*]], 0, 0<br>
>>  ; CHECK-NEXT:    br label [[END:%.*]]<br>
>>  ; CHECK:       right:<br>
>> -; CHECK-NEXT:    [[I1:%.*]] = extractvalue { { i32, i32 }, { i32, i32 } } [[AGG_RIGHT:%.*]], 0, 0<br>
>>  ; CHECK-NEXT:    br label [[END]]<br>
>>  ; CHECK:       end:<br>
>> -; CHECK-NEXT:    [[R:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I1]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[AGG_LEFT_PN:%.*]] = phi { { i32, i32 }, { i32, i32 } } [ [[AGG_LEFT:%.*]], [[LEFT]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ]<br>
>> +; CHECK-NEXT:    [[R:%.*]] = extractvalue { { i32, i32 }, { i32, i32 } } [[AGG_LEFT_PN]], 0, 0<br>
>>  ; CHECK-NEXT:    ret i32 [[R]]<br>
>>  ;<br>
>>  entry:<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>