Thứ Hai, 29 tháng 1, 2018

News on Youtube Jan 29 2018

Hi and welcome to my video! This week we are making some comfort food. There's a

version of this dish in almost every region of India. It's very easily

digestible and uses very simple ingredients that you might already have

in your pantry. If you haven't guessed already I am sharing a recipe for Khichdi.

Khichdi is best described as a salty porridge made from rice and lentils.

Sometimes it is made from other things like bajra or sabudana but for this

version I am sticking to short grain white rice and masoor dal, because they

both cook up really quickly and easily. Here's a bit of trivia for you: the

British dish known as kedgeree actually originated from Khichdi and if

you're a fan of Downton Abbey then you know that this is the first dish

mentioned by Mrs. Patmore way back in season 1 episode 1. Now, before we get

started please show my channel some love and give this video a thumbs up and hit

the subscribe button while you're at it because I post recipes every single

Monday. Now once you have all your ingredients lined up, go ahead and heat

up some ghee or oil in your pressure cooker on high heat then add the whole

cumin seeds to the hot oil. Or you can just add them from the beginning and

wait for them to crackle. Once they're crackling away it's time to add the

green chillies followed by the ginger and garlic. If you think the oil is too

hot at this point go ahead and turn it down a little bit and make sure to keep

these ingredients moving. We want them to cook and to become aromatic but we don't

want them to burn. And once you can smell their beautiful aromas go ahead and add

the turmeric powder followed by the red lentils and the rice. And I would like to

say that both the rice and the red lentils have each been soaked for 30

minutes before. I would highly recommend not missing this step. There are a lot of

benefits to pre-soaking pulses as well as rice but aside from that, it's really

going to help in the cooking process. Then stir to combine everything and add

a little bit of salt. You don't have to add a lot at this stage because you can

always adjust it once everything is cooked,

and the next step is to add water. The ratio of water is one to three-and-half

and in this instance the one refers to the combined amount of rice and

lentils. I had a cup and a half of combined rice and lentils so I used five

and a quarter cups of water. And that's water that I boiled in my kettle. That's

gonna help speed up the cooking process as well. As you could see this was

already bubbling away and that's because I used water that was already hot. Then

go ahead and shut the pressure cooker and allow this to cook on high for 3

whistles. That's what a whistle looks like right there, and in case you need

any further clarification you can check out this video I made on how to make a

simple dal and use your pressure cooker without detriment.

After the third whistle, go ahead and turn down the heat to low. This will

give you enough time to work on the tempering for your Khichdi and you only

need a couple of things for this. A whole red chilli, some curry leaves, and about a

teaspoon of coriander seeds. Start out by heating some ghee or oil in a little

skillet on high heat and just add in all of the tempering ingredients. This is an

optional step but it does add an extra layer of deliciousness to your Khichdi.

And even though this is a simple Khichdi, it's not basic. Just because this recipe

isn't complicated, doesn't mean we're going to skip steps or take any

shortcuts. By this time, all the steam should be released from your pressure

cooker so go ahead and open it up and take a minute to appreciate the vibrant

and beautiful color of this dish. You can adjust the salt if you need to at this

stage and then add the tempering right on top and combine it into the dish. This

oil that's been infused with these roasted spices is going to give such a

depth of flavor to this Khichdi and if you're in need of some culinary love

because you haven't been feeling well, you're gonna feel thoroughly comforted

when you taste this. You can certainly eat this on its own but my favorite way

to serve this is alongside some tomato salad, some plain yogurt, and mango pickle

or aam ka achaar. The complete recipe as well as the recipe for this very simple tomato

salad will be up on the blog so you can check that out if you need to otherwise

that's it! This gooey porridgey goodness is the perfect recipe for when

you're feeling just a little under the weather, and if you're wondering what

happened to that red chili I saved it for this shot right here. There it is

perfect for nibbling, and as usual thank you so much for watching and for

supporting this channel. See you next week, buh bye!

For more infomation >> How to Make a Simple Khichdi - A Pressure Cooker Recipe! - Duration: 5:16.

-------------------------------------------

Dis is a simple Meme. - Duration: 0:04.

Upgrade.

Fuck Go Back!

For more infomation >> Dis is a simple Meme. - Duration: 0:04.

-------------------------------------------

How To Stay Motivated | 3 Simple Tips - Duration: 6:15.

What's going on guys my name is Anthony Villa welcoming you back to yet another

video here on the channel where today guys I'm gonna be giving you my top

three tips you're saying super motivated super focused and working through those

rough times when you feel like doing absolutely no work at all because of

course guys everyone has those days where they're feeling super unmotivated

super not focused and when they want to do absolutely nothing but stay in bed

all day and of course guys those days are fine every once in a while but once

those days start turning into weeks weeks start turning into months and

you've gotten absolutely no work done for an extended period of time and

you're just completely messed up so to avoid lasts up guys I'm gonna start the

video right now and give you my first tip for saying super motivating and tip

number one guys is to focus on the reward because of course like I said

everyone has those days when you're having one of those days it's important

to focus on the reward remember why you started what's the end goal here what's

the reward at the end of the journey what are you gonna get and focus on that

when you're thinking about that that'll motivate you to actually start you're

doing your work or do whatever you need to do in order to reach your goal to

reach your end reward when you're feeling super unmotivated guys just

focus on that focus on the reward and that should help you push through those

lazy days that way you can still get a ton of work done and be super productive

with that being said that brings me to tip number two guys which is gonna be a

fine inspiration find things that inspire you that motivate you they

really want to make you better things that drive you for me guys one of my

biggest inspirations come from you know those books back there now of course

that's like a books right there is a nice little set proper whatever but I've

read every single one of those books and I find a ton of inspiration from some of

the authors back there you know some of them like Gary Vee Russell Brunson are

huge inspirations for me because they're super successful that's who I aspire to

be like because of what they do and how successful they are with it our course

guys your defying your own inspiration where that comes from people material

things guys I can really be anything whether it's material or not you can say

you know I really want a Lamborghini and the only I'm gonna be a Ford one is to

work my ass off so that Lamborghini inspires me to work my ass off that's

completely fine guys fine whatever inspires you and run with it looking at

on those lazy unmotivated days focus on the things that inspire you things that

drive you to be better to keep going forward and to follow your dreams

you actually meets your goals and it'll have the same result as the first one

guys the point of all this is to help me do those lazy unmotivated days where you

don't want to do anything because guys of course nobody is motivated every

single day 24/7 it's just not humanly possible so we all need a little bit of

motivation some inspiration on those days we're really not feeling it with

that being said guys that's tip number two and now I'm gonna move on to tip

number three which is gonna be to reward yourself

you guys should reward yourself for the progress that you make towards your

goals these don't have to be huge things guys it's really important that you have

small stepping stone goals on the way on the path to your big to your end goal

because of course guys if your goals look something like one start a business

and then to have a business that makes over $100,000 a year it's gonna be a

long time until you reach that second goal and your that's gonna make you feel

really unmotivated when you're not reaching that goal you're gonna feel

unmotivated because you're not really accomplishing anything you're gonna feel

like you're not progressing towards anything even though you really are

that's why it's important to have smaller stepping stone goals

accomplished as you go on the path on the journey to that bigger goal so for

example we use the same example I just said if you want to start a business

maybe have your goal have the business make something like ten thousand dollars

or it can be even smaller guys you know things like make your first sale stuff

like that it can be really small goals it doesn't have to be these huge

gigantic goals all the time that's why it's really important to have smaller

stepping stone goals because as you accomplish those when you guys when you

accomplishment goal you feel good inside you feel motivated and that motivation

will carry you to the next goal into the next school and to the next one until

you finally reach that huge end goal and then you guys can really reward yourself

then because you guys accomplished exactly what you wanted to and guys you

can reward yourself with pretty much anything you want whether that's like

Chipotle maybe that's tickets to the movies maybe

that's just taking a day off and spending time with your friend your

family and friends it doesn't matter guys as long as that

reward motivates you to accomplish it as long as the reward is something that you

really really want and it's something that you'll actually work towards

because you know that you want it then it'll be effective guys the only way any

of this stuff works is if you stick to it and be consistent with it because

guys I can't say enough I hope everybody has those days but the whole idea is to

not those days turn into weeks you can't those days string along all

the time you guys need to stay as motivated

you can and you combine all three of these tips I can almost guarantee you'll

be able to find a ton more motivation on your day to day with that being said

guys I'm gonna give you guys one more tip it's not really a tip but it's

something I wanted to include in the video and that's gonna be to take breaks

of course the entire video I've been preaching about not taking days off not

letting your days turn into weeks off and of course that's important but it's

also extremely important to take breaks when you need them like I said earlier

in the video guys nobody's motivated 24/7 every single day it's just not

humanly possible so of course everyone's gonna have those days we didn't want to

do anything and sometimes you need to realize that you're gonna need a break

because if you don't take breaks that's really that's when you'll get really fed

up and that's when you'll actually quit it's important to take breaks along the

way because guys if you have these huge gigantic goals that can take you like

six months to a year to accomplish it's important to take breaks along the way

that way you don't stress yourself out you don't tire yourself out and you

don't get burnt out working everyday because if you get burnt out working

every single day to the point where you just give up and no more progress is

happening no more works getting done and then it's all over with that being said

there guys that's pretty much the video wrapped up if you combine all four of

those things you should definitely be able to find some more motivation in

your day-to-day life and it should make it a lot easier to get through those

unmotivated unfocused days we don't want to do anything with that being said guys

if you enjoyed the video drop a like on it and definitely subscribe for brand

new videos every single day until then guys my name is Anthony Villa and I'm

out

you

For more infomation >> How To Stay Motivated | 3 Simple Tips - Duration: 6:15.

-------------------------------------------

5 Simple Daily Wear Fancy Earrings || DIY Earrings - Duration: 6:39.

Velvet beads

golden bead

headpin

eyepin

bead cap

150 strands of silk thread

Thanks for watching my videos

subscribe my channel for more videos

For more infomation >> 5 Simple Daily Wear Fancy Earrings || DIY Earrings - Duration: 6:39.

-------------------------------------------

40 Simple Home Design 3D - Duration: 4:34.

we'll show some of our favorite simple home design all shown in beautiful 3D perspective.

If you are looking for modern house plans that includes architectural drawings too,

please check out this simple home design 3d.

For more infomation >> 40 Simple Home Design 3D - Duration: 4:34.

-------------------------------------------

35 Simple Home Interior Design Ideas - Duration: 3:31.

simple home interior design not only functions well but also can create a mood or feeling

and shows off the personality of the family that lives in the home.

It's the three important things that you should give attention about home interior

design.

That is function, mood and the personality.

Before you choose the home interior design ideas, think about your family and how you

live or you can choose based on your life style or as like your dream house.

If you are getting confused to choose, you can look magazine about home interior design

ideas for inspiration and pull out ideas or room that appeal to you.

I will give you some review about simple home interior design ideas.

Enjoy!

For more infomation >> 35 Simple Home Interior Design Ideas - Duration: 3:31.

-------------------------------------------

WAR TH9 UPDATE 2018|Combo war TH9 full 3* simple, effective, fast - Part 4 - Duration: 3:05.

SUBSCRIBE FOR COC CHANNLE, THANKS!

For more infomation >> WAR TH9 UPDATE 2018|Combo war TH9 full 3* simple, effective, fast - Part 4 - Duration: 3:05.

-------------------------------------------

झटपट बनाये शकरकन्द आलू कटलेट | Simple Sweet Potato Patties | Shakarkandi Cutlets Tikki - Duration: 3:47.

sweet potato patties recipe | शकरकन्द आलू कटलेट

1 Sweet potatoes boiled - शकरकन्द

2 Potatoes boiled - आलू

1/4 cup All-purpose flour - मैदा

Peanuts crushed - मूंगफली

sweet potato patties

For more infomation >> झटपट बनाये शकरकन्द आलू कटलेट | Simple Sweet Potato Patties | Shakarkandi Cutlets Tikki - Duration: 3:47.

-------------------------------------------

Head, Shoulders, Knees & Toes Exercise Song for Children Family fun | simple kids songs TV - Duration: 1:13.

Head, Shoulders, Knees & Toes Exercise Song for Children Family fun | simple kids songs TV

For more infomation >> Head, Shoulders, Knees & Toes Exercise Song for Children Family fun | simple kids songs TV - Duration: 1:13.

-------------------------------------------

7 Simple Ways to Get Healthier With Minimal Effort - Duration: 4:36.

For more infomation >> 7 Simple Ways to Get Healthier With Minimal Effort - Duration: 4:36.

-------------------------------------------

Simple AST Optimizations — How to Create a Compiler part 2/5 - Duration: 28:45.

Good evening! [In Arabic language]

In the last episode,

we created a parser for a B-like programming language.

It parses each function into a tree structure,

where expressions contain expressions.

Today we will focus on optimization.

As I have said before,

much in programming is actually work –

towards making the work itself easier.

The code I wrote so far –

does not single-mindedly just aim towards the end result.

Code like this, for instance, helps constructing expressions –

using much shorter code than would be otherwise necessary.

In that similar mindset, these functions I just added –

help identifying the type of the expression or identifier.

However today the video topic is optimization.

In the interest of getting this video out in reasonable time,

I am going to compromise a little bit on good programming practices.

I start by taking the list of functions out –

from inside the main program,

and moving it into a global variable.

This will simplify the rest of this episode quite a bit.

Much of the optimizations in today's episode –

concern with replacing code with simpler alternatives –

that accomplish the same outcome.

One of the most important factors,

that decide whether some code can be replaced with some other code –

is whether that code has side-effects or not.

A side-effect is when an expression produces any other outcome –

than its return value.

In this is_pure() function,

we already wrote some basic rules in episode 1,

but so far we assumed that –

any function call automatically taints the expression as inpure.

This is not necessarily the case.

Calling a pure function,

such as one that simply returns the sum of two variables,

is a pure expression.

For example, replacing two calls to the same function with one call,

or deleting the call entirely,

will not change how the program works –

assuming the same result is calculated.

We need a way to classify functions.

This is more complicated than it sounds;

the pure_fcall cannot just make the decision when it is called.

Instead, if will check a precalculated variable.

There is one variable that indicates whether the function is pure,

and another that tells –

whether we even know whether the function is pure or not.

Of course, we need a way to calculate these variables.

My language does not have any global variables,

but it has pointers.

If a function takes a pointer parameter,

and it dereferences a pointer on the left side of an assign operator,

we can assume the function has side-effects.

It causes changes outside strictly its return value.

Of course, the effect is commutative.

No, viral.

No, what's the term for that?

If the function calls another function that has side-effects,

this function, too, will have side-effects.

Because the dependency chain between functions may run in any order,

we must loop this resolving process –

until we no longer can label any function as certainly pure or impure.

To implement this function right now,

we needed a special kind of for-loop –

that iterates through all sub-expressions in an expression tree.

Here is how I defined the for_all_expr function.

It operates on the depth-first principle.

The first node to be processed will be the deepest possible child node.

After all child nodes have been processed,

only then does the parent node get processed too.

For convenience's sake,

I decided to support two kinds of functors.

Those which return a boolean value, false or true,

to indicate whether the caller found whatever it looked for,

and the processing should be stopped immediately,

and those that return nothing.

To support both conventions, a helper function is needed,

that unifies both types of functions.

If the provided functor returns nothing,

this function returns the default parameter given.

Otherwise it returns whatever the functor returns.

I am surprised that –

there is not such a function already in the standard library.

While we are at it,

let's add a function that compares two expressions –

and tells whether they are equal.

This will be very helpful later.

The first category of optimizations is called "constant folding".

We are going to walk through every single expression in the code,

and optimize them using this ConstantFolding function.

We begin by checking the type of the expression.

If the expression is, say, a negate operation,

and the parameter is an integer constant,

we can replace the negate operation with the negated integer constant.

If the expression is an equals-comparison,

and both operands are integer constants,

we can perform the comparison at compile-time –

and simply replace the expression with an integer constant,

zero or one.

The same can be done if the operands are identical pure expressions.

Actually, the name of this function is a bit of a misnomer.

This function does all sorts of simplifications.

For instance, pointer expressions can be simplified,

if an address-of operator is immediately followed by a dereference operator,

or vice versa.

If an assign-statement has the same expression on both sides,

the assign-operation is redundant –

and can be replaced with the source operand,

assuming the operand has no side effects.

If we know at compile time that a loop operation will never loop,

we can delete the entire loop statement.

Now the add-operation requires much more work.

Let's get back to that later,

because there is a certain general principle we must take care of first.

Let me show you what I mean.

This is the tree structures that the compiler generates –

when it parses an add-expression that contains four operands.

It generates three add-expressions, that each have two operands.

But the thing is, this exact same outcome –

can be accomplished with many different structures.

Some of these work only because the add-operator is commutative,

meaning the order of operations does not matter,

but the simplest possible structure is the one shown in the lower-right corner,

where we have exactly one add-operator, and four parameters.

Interestingly enough, this same optimization can be performed –

on some operators that are not commutative,

as long as you keep the order of execution unchanged.

For example the and-operator.

All of these trees perform the same sequence of operations,

but again the fourth one is the simplest one.

So for add, comma, logical or, and logical and operators,

check if any child expression is the same type as the parent expression.

For every such child that is found, adopt the grandchildren directly.

Now the add-expression may contain an assorted mixture –

of all kinds of expressions, including number literals.

Just in case there are multiple number literals in the add-group,

or maybe there is a zero there, we'll quickly sum them up.

If the sum is nonzero, we'll add it back.

While we are at it, we can also convert negations –

into a slightly more efficient format.

After all this work, there is a possibility –

that the expression has been reduced into just a single operand,

or possibly into nothing at all.

In such cases, the expression can be reduced further.

But we are only getting started!

Next let's tackle the && and || operators.

Consider this example expression.

Consider how this is evaluated.

First, "a" is checked.

If it is zero, the process stops and the && evaluates into 0.

Otherwise, "b" is checked.

If it is zero, the process stops and the && evaluates into 0.

Otherwise, one is checked.

Well, one is not zero.

So the next expression is checked.

"x" is stored into "c".

If the result is zero, the process stops and the && evaluates into 0.

Otherwise, "d" is checked.

If it is zero, the process stops and the && evaluates into 0.

Well, zero is zero.

So the process stops and && evaluates into 0.

There are two observations to be made here.

The value of "e" was never checked,

because the literal zero that preceded it –

meant that nothing that comes after it is evaluated!

Also, because of the presence of the zero,

we know the && expression always returns zero in this case.

Technically, all of these expressions that we evaluated were useless.

We can optimize the expression like this.

The literal 1 expression was deleted,

because that cannot contribute to the result in any manner.

"e" was also removed, because it is never evaluated.

"d" was removed too,

because this expression has no side-effects,

so it does not influence the outcome in any manner.

However, neither "a" nor "b" can be removed,

because their values determine –

whether the assignment expression gets executed or not.

The assignment expressions is not a pure expression,

so it cannot be deleted either.

Finally, because we already know what the && operator will return:

always a zero,

we can simply ignore the return value –

and just return a literal zero using a comma operator.

This may benefit other optimizations that come later.

The || operator works exactly the same,

except that the consequences of zero and nonzero are reversed.

So, delete all operands that cannot possibly change the outcome.

If an operand is encountered –

that shortcuts the evaluation and forces the outcome,

delete all operands that came after that operand.

Next, we tackle the comma expressions.

This is where it gets complicated,

but let's start gentle.

Comma expressions are basically sequences of operations.

If we encounter an operation –

that prevents anything after it from being executed,

such as a return statement,

the remaining operations in the comma can be deleted.

This is one particular special case that I also deal with here.

Have a look at this comma expression.

No, wait.

This one.

That's actually an optimization I am yet to write.

Here.

This is a comma expression.

A sequence of assorted operations.

Only the result of the last expression is important;

In this case it is the assignment into z.

But expressions with side-effects have to be kept too.

While the dereference of "s" is not an expression with side-effects,

and of course neither is plus operation on the far left side,

the assignment operation has side-effects, so that one has to be kept.

So, we loop through all the parameters.

Any pure expressions, except the last, will be deleted.

However, even if the expression is not pure,

its impurity may be limited.

For certain types of expressions,

we can skip over the calculation and just rob the operands.

We can also apply the exact same logic into while-loops,

as long as we are careful –

to not accidentally delete the loop condition expression.

Consider this expression: x + 3 + (y = 4)

This expression accomplishes two things:

It assigns y := 4.

And it returns a value.

What does it return?

It returns x + 7.

However, currently the code cannot optimize this as x + 7,

because the 4 is hidden inside the parenthesis-expression.

A naïve attempt would be to sum these two numeric literals,

which would produce this expression.

But this would be a blunder.

While the expression does now correctly return x + 7,

it no longer assigns y := 4.

It now assigns y := 7.

So we cannot do that.

The correct way to optimize is shown on the right.

A comma expression is created between the = and + operations,

and the right-hand side of the assign expression is duplicated.

This way,

other optimizations will eventually convert this expression like this.

The result is exactly what we wanted in the first place:

y := 4, and then x + 7 is calculated and this value is the result.

However!

If the right-hand side of the assign expression has side-effects,

the optimization I proposed here would be a mistake,

because it causes the expression to be evaluated twice.

This is what must be done instead.

The result of the side-effect expression is assigned into a temporary variable,

and that temporary variable can be then copied –

as many times as necessary.

The next operation is fascinating.

Consider this example expression: z := the sum of x++ and y++.

The parser generates this complicated tree for this expression.

There are two comma expressions,

and the sum of these comma expressions is assigned into z.

This is what we can convert it into.

Two things have happened here.

First, the comma expressions from the inside of the outer sum expression –

have been extracted, so that only the last components –

of the comma expressions are retained in the sum.

Then, the assign into z is moved inside the comma expression.

This produces an overall much flatter tree structure than we started with.

Where there were six nested levels of expressions before,

there are now at most three,

yet it still behaves exactly the same as before.

We can also do the same operation –

for the first element in && and || expressions,

as long as we only operate on the first element.

We begin by scanning the parameter list –

backwards from the end anchor, until we find a comma expression.

This delimits the parameters into two sections.

The first section will be processed.

If there is a comma expression,

its parameters will be moved into the outer comma expression,

except for the last one.

If something was moved,

then this expression is replaced with a comma –

where the original expression is its last item.

However,

for anything except the last parameter in the first section,

the expression is moved into a temporary variable –

and that temporary variable is put in its place.

This ensures the unchanging of the evaluation order –

of different expressions.

Now if we take these rules for the "if" expression,

and try to apply it to the "while" expression verbatim,

we will produce incorrect behavior.

In the original expression, x gets incremented on each loop,

but in this modified form, x gets incremented only once,

before the loop.

Here is how it must be corrected.

The parts that were extracted –

from inside the loop to the outside of the loop –

must be replicated at the end of the loop.

Yes, this optimization may actually make the code longer.

But it has to be done,

if we wish to enable certain other optimizations to work.

Now you may have noticed that –

this optimization function does not necessarily bring out –

the best possible result immediately.

It may have to be run multiple times.

We will simply run this loop as long –

as running the optimization for one of the functions –

produces any changes to the structure.

I created a couple of testcases to make sure this works as intended.

In this layout, on the top you can see the original code.

On the left, what the parser produced for this code,

and on its right side, how it was optimized.

This first example shows how powerful the add-expression flattener is.

You can also see it calculated the sum of 4 + 7 at compile time,

despite them being in separate sub-expressions.

In the second example I modified the numbers so that their sum is zero.

You can see the integer literal is completely absent –

from the optimized output,

because adding zero to something would not accomplish anything.

The third example experiments with the negation operations.

The original expression contains five negations,

but the optimized expression contains only four.

You can verify this on pen and paper,

if you don't believe this optimization was correct.

The simple removal of two consecutive neg-operations seems to work alright.

An odd number of neg-operations still retains one, as it should.

Pairs of address-of and dereference operations get reduced, too.

This is one of the tests for the comma reducer.

Ignore the first two functions;

they are just artificial examples –

of pure and impure functions for the sake of the test.

The actual test function contains a sequence of five statements,

plus the implicit return statement.

As we can see, the optimizer detected all the pure expressions –

and deleted them.

The last expression in the list is kept, even though it is pure,

because it is returned as the function return value.

This testcase has three functions.

In the top example, x is stored into x.

Somehow it gets optimized into nothing.

How come?

Let's look at the middle function first.

x is stored into x, and then it is returned.

Storing a variable into itself –

gets optimized into just the variable itself.

Now, when we look back at the first function,

we can guess what happened.

First, the self-assignment got optimized as just the variable.

Then, the variable was removed,

because it was a pure expression in a comma statement.

The assignment was not a pure expression,

but the variable alone was pure.

So it got removed.

Only the return statement remains.

In the third function,

the left-hand side and the right-hand side –

of the assign expression are not identical,

so the assignment was not removed.

However, the source operand was duplicated for the return value.

And here it seems there is actually a bug in my design!

If you pass, say, number eight, as a parameter to this function,

you would expect that the function returns nine.

But the "optimized" version first increments the variable once,

and then increments it again when returning,

so it actually returns ten instead of nine!

This is a bug that must be fixed!

Let's make a note about that.

This is why we test.

Here is another example of the comma optimization.

Here, this function contains two return statements.

The second return statement can never be reached,

so the optimizer deleted it.

The function always returns 100.

In this example we have two while-loops.

The first while-loop will never run,

because the loop condition is known at compile-time to be false.

So it was deleted.

The second while-loop, on the other hand,

never terminates.

It is an infinite loop.

So any code that comes after that is dead code;

it can never be reached.

So the rest of the code was deleted by the optimizer.

Then we have the && sequence.

This is exactly the same example as earlier at 9:21 in this video.

The one was deleted, because it cannot change the result.

The zero was deleted, because it forces the result.

The "e" was deleted, because it would never be evaluated –

because of the zero.

This is the || version.

Here, because the compiler knows at compile-time –

that this || expression will always match because of the 1-literal,

it made that assignment into x explicit rather than conditional.

This function does two postincrements.

There is nothing too interesting about this test,

other than that the optimized tree is a great deal simpler than the original one.

The optimizer did not notice –

that the value of "x" is never used after it is incremented,

and technically it could delete the whole addition,

but that's all right:

I didn't write that kind of optimization yet.

We will get to that topic in the third or fourth episode.

This is almost the same as the previous one,

except now we have a function call instead of an addition.

There is something weird here.

Notice the function call?

It seems to have created a temporary variable,

stored a function pointer into that variable,

and then called the function indirectly at the end.

This is not incorrect behavior, but it is certainly odd,

and very likely a pessimization.

I will have to fix that.

This is the optimization –

that I explained in great detail at 14:11 in this video.

The assign expression is flattened out –

in order to make the add-expression optimizable…

But something is wrong here.

The compiler has created a temporary variable –

for the number three literal,

and this blocks the optimizer –

from performing the very purpose it was designed to do.

I will have to fix this too!

The problem with the last two tests –

was that the compiler created temporary variables –

for simple expressions that were effectively compile-time constants.

The is_pure() function is not enough to detect these situations.

We need a second classification method –

that determines whether an expression conveys a compile-time constant.

A compile-time constant is a number literal –

or a string literal, or a function identifier,

or any simple expression –

that consists of only compile-time constants.

We can immediately use this function to simplify some existing code.

So here!

This is the loop –

that hoists sub-expressions out from parents –

and replaces them with temporaries.

We will just simply check that –

if the expression is a compile-time constant,

the hoisting is not performed.

Done.

Then there was that problem with the x+1 assignment going wrong.

This is easiest to fix here, when checking for the self-assignment.

In short,

if the target expression is also used in the source expression,

a temporary variable will be created,

and that temporary variable will be referred to –

in each location in the source expression.

Then, it no longer matters if the temporary variable gets duplicated.

Now let's get back to test 7.

This is how it changed.

The +1 expression still gets duplicated, but the function does not change;

a bug is not introduced, which is the most important thing.

It would be nice,

if the whole source expression did not have to be duplicated —

it really does not need to be duplicated —

but no optimizer is perfect.

If I copied the target expression instead of the source expression,

that plus-seven optimization would be impossible.

Speaking of that.

This is what happens when the source expression is not duplicated properly,

but dubious temporary variables are created.

And we fixed that.

Now, it gets optimized properly as was originally intended,

thanks to the compile-time constant detection.

Technically that assignment into a temporary variable –

is unnecessary here, but it does not hurt.

In the next episode –

we will deal with a whole new category of optimizations –

that makes all these temporary variables not matter in the least.

We will create a register-based intermediate language –

that is one step closer to actual machine code.

Subscribe to my channel and click the bell icon –

to make sure you won't miss one episode!

As always, thank you for all your support.

In case you have questions,

make sure you first check the video description,

the links in the video description; and the top-fiveish comments —

to make sure your question has not been already answered twenty times.

I do appreciate and heartily welcome all of your comments,

thumbsups, shares, and so on,

but it will make things faster for you –

if you just spent ten seconds –

looking first whether your question has already been answered.

Have a most pleasant and fulfilling day!

See you again! [In Arabic language]

For more infomation >> Simple AST Optimizations — How to Create a Compiler part 2/5 - Duration: 28:45.

-------------------------------------------

DIY Simple Cucumber Gel For Skin Whitening,Glowing,Clear & Brighter Skin By Rani G in Urdu/Hindi - Duration: 5:37.

Please SUBSCRIBE Rani G Health & Beauty Tips

For more infomation >> DIY Simple Cucumber Gel For Skin Whitening,Glowing,Clear & Brighter Skin By Rani G in Urdu/Hindi - Duration: 5:37.

-------------------------------------------

Simple Cabbage Sabzi | पत्ता गोभी की सब्ज़ी | Lunch Box Recipes | Easy Gobhi Recipe In Hindi | Varun - Duration: 4:03.

For more infomation >> Simple Cabbage Sabzi | पत्ता गोभी की सब्ज़ी | Lunch Box Recipes | Easy Gobhi Recipe In Hindi | Varun - Duration: 4:03.

-------------------------------------------

HOW TO GET RID OF A PACIFIER / DUMMY - SIMPLE TIPS ON WEANING YOUR BABY OFF THE SOOTHER - Duration: 19:40.

For more infomation >> HOW TO GET RID OF A PACIFIER / DUMMY - SIMPLE TIPS ON WEANING YOUR BABY OFF THE SOOTHER - Duration: 19:40.

-------------------------------------------

Ce bébé décède après un simple bisou, la raison de sa mort est effrayante - Duration: 2:02.

For more infomation >> Ce bébé décède après un simple bisou, la raison de sa mort est effrayante - Duration: 2:02.

-------------------------------------------

Curly Locks Curly Locks Super Simple Nursery Rhymes With Lyrics | 3D Animation Kids Nursery Rhymes - Duration: 1:23.

Curly Locks Curly Locks Super Simple Nursery Rhymes With Lyrics 3D Animation Kids Nursery Rhymes

Không có nhận xét nào:

Đăng nhận xét