[llvm] 1f90d45 - [InstCombine] PHI-of-extractvalues -> extractvalue-of-PHI, aka invokes are bad

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 00:49:50 PDT 2020


On Wed, Sep 9, 2020 at 6:19 AM Eric Christopher <echristo at gmail.com> wrote:
>
> Hi Roman,
Hi.

> This seems like a pretty good idea,

> but the change to EarlyCSE seems to be necessary before disabling a bunch of optimization?
> Or am I misreading the comment in the commit?
I really don't see what you mean.
Nothing in that commit message talks about the need for an EarlyCSE change,
or about "disabling a bunch of optimization". What it does talk about,
is that we may want an InstCombine-based PHI CSE, and we got that
in https://reviews.llvm.org/rGbf21ce7b908e16db76f5704714ee83e61a9da95b

> 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?
Note this patch isn't a standalone "let's have less `extractvalue`e",
but it belongs to the series of folds designed to ensure that as many
`invoke`s as possible are no longer `invoke`s, but are converted into `call`s,
which, i think you'll agree, generally allows much more optimizations.

That end goal is almost a correctness thing, while the patch is just
an exploratory step. As i've since established with certainty
(https://reviews.llvm.org/D86530#2247674), i'll need a more
general approach, so *in principle* this particular
change could go away afterwards.

But no, i haven't observed any notable (above the noiselevel)
performance changes in this patch.

> -eric


Roman

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


More information about the llvm-commits mailing list