Page MenuHomePhabricator
Feed Advanced Search

Feb 5 2022

vdsered updated the diff for D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.
  1. Rebased
  2. If EnableOptimizationAcrossLoops is false, then DSE does not run twice
  3. Added two more negative tests cases
  4. Removed loop transformations from this pass
  5. Skip killing store which is not guaranteed to execute
Feb 5 2022, 10:35 AM · Restricted Project

Feb 2 2022

vdsered added a comment to D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.

@vdsered are you still planning on pushing this forward?

I think this would have nontrivial impact on compile time (@nikic ?) and the results from testsuite do not look so promising - I would expect more “hits” to justify (small if possible) compile time regression.

Yes, this has a large negative effect: https://llvm-compile-time-tracker.com/compare.php?from=64eaffb613d0cb7fa7542fa48281a2e617ad8ee9&to=6e7452757e16c4260fa9a5862761a68ed778dbf9&stat=instructions

Agreed that the compile-time impact looks very large, but I *think* it may not be as bad as it looks at the moment. There seems to be a bug in the code that means we effectively run the main DSE loop twice if EnableOptimizationAcrossLoops = false (as in this patch).

Thee patch unconditionally runs the whole main DSE loop again, as below. prepareStateForAcrossLoopOptimization has en early exit if !EnableOptimizationAcrossLoops. Otherwise clears MemDeps and roughly only adds MemDeps with loop ranges. So as a consequence, if !EnableOptimizationAcrossLoops we process *all* MemoryDeps again.

MadeChange |= State.prepareStateForAcrossLoopOptimization();
MadeChange |= runDSEOptimizationLoop(State);

I tried to rebase the patches and collect compile-time numbers with that issue fixed: https://llvm-compile-time-tracker.com/compare.php?from=f622c7b7d33b211517d8fe4f725d1028d786fc08&to=00a8810b123e606c19d9926d11183318323a8752&stat=instructions

NewPM-O3: +0.24%
NewPM-ReleaseThinLTO: +0.39%
NewPM-ReleaseLTO-g: +0.26%

We should still see if we can get those down further, but I think they look more encouraging to start with.

Feb 2 2022, 8:46 PM · Restricted Project

Dec 16 2021

vdsered added inline comments to D115602: [X86] Memset is lowered to rep stos if MinSize is present.
Dec 16 2021, 7:45 AM · Restricted Project
vdsered added a comment to D115602: [X86] Memset is lowered to rep stos if MinSize is present.

I don't remember seeing this part of x86 codegen before, so adding some more reviewers. I'm also not sure what is recommended as the best perf x86 asm on recent CPUs. Should we be using this for "optsize" too?

Dec 16 2021, 7:23 AM · Restricted Project

Dec 12 2021

vdsered added a comment to D115602: [X86] Memset is lowered to rep stos if MinSize is present.
Dec 12 2021, 11:21 AM · Restricted Project
vdsered set the repository for D115602: [X86] Memset is lowered to rep stos if MinSize is present to rG LLVM Github Monorepo.
Dec 12 2021, 11:13 AM · Restricted Project
vdsered requested review of D115602: [X86] Memset is lowered to rep stos if MinSize is present.
Dec 12 2021, 11:12 AM · Restricted Project
vdsered committed rG9633df04d9b2: [NFC][X86] Precommit tests for memset with minsize being present (authored by vdsered).
[NFC][X86] Precommit tests for memset with minsize being present
Dec 12 2021, 10:45 AM

Nov 1 2021

vdsered abandoned D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.
Nov 1 2021, 10:44 AM · Restricted Project

Oct 5 2021

vdsered added a comment to D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.

Hi, @xbolva00. Are you sure that we can use loop idiom and transform arbitrary loop with a store into let's a memset?

Oct 5 2021, 8:42 AM · Restricted Project
vdsered added a comment to D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.

Results for current patch for SingleSource/MultiSource are in the table below. Other don't show any different. Metric is dse.RemainingNumStores

Oct 5 2021, 8:25 AM · Restricted Project
vdsered updated the diff for D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.
  • Transform loops into loop rotated simplify form
  • Use guards instead of directly finding icmps
  • Implemented optimization for loop + loop
  • Decreased the number of times when we compute range for memory intrinsics
  • Running DSE loop twice, 1 as it was before and 2 for optimization across loops
Oct 5 2021, 8:15 AM · Restricted Project

Sep 27 2021

vdsered added a comment to D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.

Loops lose simplify form in JumpThreading in default pipeline before DSE, for example. I don't know the details and if this is correct or not. There is currently no need for a loop to be in simplify form in DSE in order to work with it (except that it should be a natural loop). It became only required for my optimization.

Sep 27 2021, 9:04 AM · Restricted Project

Sep 26 2021

vdsered updated the summary of D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.
Sep 26 2021, 1:05 AM · Restricted Project
vdsered updated the summary of D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.
Sep 26 2021, 12:42 AM · Restricted Project
vdsered updated the summary of D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.
Sep 26 2021, 12:31 AM · Restricted Project
vdsered requested review of D110492: [LoopInfo] Return conditional branch of preheader's predecessor if loop's exit has exactly two predecessors which are latch and guard.
Sep 26 2021, 12:28 AM · Restricted Project

Sep 15 2021

vdsered updated the diff for D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.
  1. Simplified code by removing unnecessary if-statements
  2. Turned AddMemRange lambda to a method
  3. memset can be eliminated when memset has constant length and loop has constant iteration count + added a test for this
Sep 15 2021, 11:09 AM · Restricted Project

Sep 9 2021

vdsered added a comment to D90095: [DSE] Enable MSSA DSE to optimize across PHIs.

@ebrevnov I see that in memoryIsNotModifiedBetween function and there is some sort of a local phi-translation (I mean it is used only inside this function) as I understand. Do we need to update this function somehow?

Sep 9 2021, 11:30 AM · Restricted Project

Sep 8 2021

vdsered updated the diff for D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.

Rebase + fixed opt-pipeline.ll tests for AMDGPU

Sep 8 2021, 8:20 PM · Restricted Project
vdsered updated the diff for D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.
  1. Added one test for a loop with several latches where we don't always overwrite the region where memory intrinsic writes to
  2. Fixed formatting
  3. Replaced typed pointers with opaque pointers (--force-opaque-pointers is used in tests)
  4. Fixed crash caused by an assertion for multiplication of operands with different types
  5. Optimized ContinuousMemoryRegion and removed one field from there
  6. Added a feature flag EnableMemIntrinsicEliminationByStores to enable/disable this feature at runtime (probably not the best naming)
Sep 8 2021, 1:38 PM · Restricted Project

Sep 4 2021

vdsered requested review of D109280: [WIP][DSE] Memory intrinsics like memset, memcpy, memmove are removed if they are overwritten by a store in a loop.
Sep 4 2021, 1:45 PM · Restricted Project

Jul 9 2021

vdsered added inline comments to D98288: [DSE] Translate killing locations through phis..
Jul 9 2021, 9:23 AM · Restricted Project
vdsered added inline comments to D98288: [DSE] Translate killing locations through phis..
Jul 9 2021, 9:22 AM · Restricted Project

Jun 28 2021

vdsered added a comment to D90095: [DSE] Enable MSSA DSE to optimize across PHIs.

@ebrevnov
Hi, any progress on the patch? I'd like to work on it if you agreed to that.

Jun 28 2021, 1:44 AM · Restricted Project

Jun 18 2021

vdsered committed rG6643e51d79d7: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X) (authored by vdsered).
[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)
Jun 18 2021, 2:38 AM
vdsered added a reverting change for rG31053338c97b: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X): rG6de741de08a1: Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)".
Jun 18 2021, 12:21 AM
vdsered added a reverting change for D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X): rG6de741de08a1: Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)".
Jun 18 2021, 12:21 AM · Restricted Project
vdsered committed rG6de741de08a1: Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)" (authored by vdsered).
Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)"
Jun 18 2021, 12:21 AM
vdsered committed rG31053338c97b: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X) (authored by vdsered).
[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)
Jun 18 2021, 12:14 AM
vdsered closed D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).
Jun 18 2021, 12:14 AM · Restricted Project

Jun 17 2021

vdsered committed rGaea67232b1ee: [InstCombine][NFC] Added tests for mul with zext/sext operands (authored by vdsered).
[InstCombine][NFC] Added tests for mul with zext/sext operands
Jun 17 2021, 9:15 PM

Jun 15 2021

vdsered added a comment to D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).

@lebedev.ri I don't have commit access

Jun 15 2021, 2:57 AM · Restricted Project

Jun 13 2021

vdsered added a comment to D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).

We're going to see difference only in tests @mul_bool_sext_one_extra_user and mul_bool_sext_one_user as other transformations are performed even without the change in the patch. Can someone push baseline tests to show that in the diff?

Jun 13 2021, 11:15 PM · Restricted Project
vdsered added a reviewer for D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X): lebedev.ri.
Jun 13 2021, 11:11 PM · Restricted Project
vdsered updated the diff for D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).
  1. Added an equality check of operands (previously checked if they have exactly one user)
  2. Added more tests
Jun 13 2021, 11:10 PM · Restricted Project
vdsered added a comment to D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).

I think I should update the patch because LLVM already handles zext

%sx = zext i1 %x to i32
%r = mul i32 %sx, %sx
ret i32 %r
Jun 13 2021, 8:18 AM · Restricted Project
vdsered added a comment to D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).

Correction: what i meant to say is, there are two cases:

  1. X == Y, in which case we do not care about use count. this implicitly handles the case where both operands are the same instruction
  2. either operand is one-use
Jun 13 2021, 7:52 AM · Restricted Project
vdsered requested review of D104193: [InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X).
Jun 13 2021, 6:39 AM · Restricted Project

Jun 7 2021

vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

Sorry, I didn't see you have already committed :)

Jun 7 2021, 5:17 AM · Restricted Project
vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
Jun 7 2021, 5:16 AM · Restricted Project

Jun 6 2021

vdsered added inline comments to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
Jun 6 2021, 6:48 PM · Restricted Project
vdsered updated the diff for D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

Removed name diff in tests

Jun 6 2021, 6:44 PM · Restricted Project

Jun 5 2021

vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

@spatel Done

Jun 5 2021, 9:08 AM · Restricted Project
vdsered updated the diff for D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
Jun 5 2021, 9:08 AM · Restricted Project
vdsered updated the diff for D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
Jun 5 2021, 2:51 AM · Restricted Project

Jun 1 2021

vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

@spatel you mentioned one more optimization with sext that we miss because of too strict use-constraint here. I'll create another patch for that. I think, it's going to be the last one. I don't know any other transformations for mul/fmul that would benefit from the new method.

Jun 1 2021, 10:27 AM · Restricted Project
vdsered updated the diff for D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
  1. Replaced hasOneUse + equality of operands with isOnlyUserOfAnyOperand
  2. FMF are added to produced fadd
  3. Added negative tests
Jun 1 2021, 10:20 AM · Restricted Project
vdsered added a comment to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

I ask someone to commit the patch if there are no any barriers left for that (Roman's agreement?). I don't have commit access.

Jun 1 2021, 4:04 AM · Restricted Project

May 27 2021

vdsered added a comment to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Waiting for approval of other reviewers

May 27 2021, 9:08 PM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 27 2021, 8:11 PM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 27 2021, 4:00 AM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Rebasing + updated tests with multiple uses in fmul

May 27 2021, 3:36 AM · Restricted Project

May 25 2021

vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

isOnlyUserOfAnyOperand uses hasOneUser to figure out if at least one of ops has only one user

May 25 2021, 8:44 AM · Restricted Project

May 24 2021

vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Moved isOnlyUserOfAnyOperand to Instruction class

May 24 2021, 7:47 AM · Restricted Project
vdsered added inline comments to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 24 2021, 7:04 AM · Restricted Project
vdsered added a comment to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

As I understand it

May 24 2021, 6:51 AM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Removed irrelevant comments

May 24 2021, 5:49 AM · Restricted Project
vdsered added inline comments to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 24 2021, 5:14 AM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Replaced std::any_of with llvm::any_of and used I->operands() instead of making range directly via begin/end

May 24 2021, 5:12 AM · Restricted Project

May 19 2021

vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 19 2021, 9:56 PM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 19 2021, 8:07 AM · Restricted Project
vdsered added inline comments to D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 19 2021, 6:50 AM · Restricted Project
vdsered updated the diff for D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).

Updating diff

  1. Fixed warnings of clang-tidy
  2. Refactored implementation for this patch
May 19 2021, 6:40 AM · Restricted Project

May 18 2021

vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

I created a new patch https://reviews.llvm.org/D102698. I will update the current patch when we close the new one.

May 18 2021, 9:57 AM · Restricted Project
vdsered requested review of D102698: [InstCombine] Relaxed constraints of uses for exp(X) * exp(Y) -> exp(X + Y) and exp2(X) * exp2(Y) -> exp2(X + Y).
May 18 2021, 9:51 AM · Restricted Project

May 17 2021

vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

I have noticed that there are two similiar transformations below exp2(X) * exp2(Y) -> exp2(X + Y) and exp(X) * exp(Y) -> exp(X + Y) that are done when each operand of multiplication has exactly one use which is n't true if, for example, there is exp2(X) * exp2(X) where exp2(X) is the same instruction, so it can be improved a little. I'm going to update the patch

I recommend that you make that use-check logic into a helper function as a preliminary step, so it can be be accessed from other places. For example, we miss this transform too because the use check is too restrictive:
https://alive2.llvm.org/ce/z/27ryac

May 17 2021, 11:59 AM · Restricted Project
vdsered added a comment to D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

I have noticed that there are two similiar transformations below exp2(X) * exp2(Y) -> exp2(X + Y) and exp(X) * exp(Y) -> exp(X + Y) that are done when each operand of multiplication has exactly one use which is n't true if, for example, there is exp2(X) * exp2(X) where exp2(X) is the same instruction, so it can be improved a little. I'm going to update the patch

May 17 2021, 5:44 AM · Restricted Project

May 16 2021

vdsered updated the diff for D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.

Calling CreateBinaryIntrinsic instead of CreateIntrinsic for better readability

May 16 2021, 4:36 AM · Restricted Project
vdsered requested review of D102574: [InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math.
May 16 2021, 4:03 AM · Restricted Project

May 1 2021

vdsered added a comment to D101685: [IndVarSimplify][NFC] Removed mayThrow from if-condition in predicateLoopExits of IndVarSimplify.

@reames, I don't have commit access. Can you commit the patch?

May 1 2021, 11:55 PM · Restricted Project
vdsered retitled D101685: [IndVarSimplify][NFC] Removed mayThrow from if-condition in predicateLoopExits of IndVarSimplify from Removed mayThrow from if-condition in predicateLoopExits of IndVarSimplify to [IndVarSimplify][NFC] Removed mayThrow from if-condition in predicateLoopExits of IndVarSimplify.
May 1 2021, 12:23 AM · Restricted Project
vdsered requested review of D101685: [IndVarSimplify][NFC] Removed mayThrow from if-condition in predicateLoopExits of IndVarSimplify.
May 1 2021, 12:21 AM · Restricted Project

Mar 9 2021

vdsered updated the diff for D98235: [InstCombine][SimplifyLibCalls] An extra sqrtf was produced because of transformations in optimizePow function.
Mar 9 2021, 9:56 PM · Restricted Project
vdsered added inline comments to D98235: [InstCombine][SimplifyLibCalls] An extra sqrtf was produced because of transformations in optimizePow function.
Mar 9 2021, 9:42 PM · Restricted Project
vdsered updated the diff for D98235: [InstCombine][SimplifyLibCalls] An extra sqrtf was produced because of transformations in optimizePow function.
Mar 9 2021, 9:39 PM · Restricted Project

Mar 8 2021

vdsered updated subscribers of D98235: [InstCombine][SimplifyLibCalls] An extra sqrtf was produced because of transformations in optimizePow function.
Mar 8 2021, 10:54 PM · Restricted Project
vdsered requested review of D98235: [InstCombine][SimplifyLibCalls] An extra sqrtf was produced because of transformations in optimizePow function.
Mar 8 2021, 10:53 PM · Restricted Project