Pong-like game in C++ and Allegro5
I see a number of things that could help you improve your program.

Fix the formatting

Perhaps the indentation problem is partly a cut-and-paste problem when you put it into the question, but the resulting formatting is not good, with very little indenting of code.

Fix the bugs

In this line

if (ev.type = ALLEGRO_EVENT_KEY_DOWN)


It's likely that you don't actually mean to assign the value but to test it, so it should be written instead like this:

if (ev.type == ALLEGRO_EVENT_KEY_DOWN)


Eliminate unused variables

Unused variables are a sign of poor code quality, so eliminating them should be a priority.  In this code, d, f and ballmmoving are all unused according to my compiler also tells me that.  Your compiler is probably also smart enough to tell you that, if you ask it to do so. 

Eliminate global variables

My rewrite of this code uses no global variables, so clearly they are neither faster nor necessary.  Eliminating them allows your code to be more readable and maintainable, both of which are important characteristics of well-written code.  Global variables introduce messy linkages that are difficult to spot and error prone.

Check return values for errors

The calls to al_load_bitmap, al_create_event_queue, etc. can fail.  You should check the return values to make sure they did not.  

Eliminate "magic numbers"

This code is littered with "magic numbers," that is, unnamed constants such as 400, 7, 600, etc.  Generally it's better to avoid that and give such constants meaningful names.  That way, if anything ever needs to be changed, you won't have to go hunting through the code for all instances of "800" and then trying to determine if this particular 800 means the width of the window or some other constant that happens to have the same value.

Break up the code into smaller functions

Rather than having everything in one long function, it would be easier to read and maintain if each discrete step were its own function.

Think of the user

Right now there is no graceful way to end the game.  This could easily be addressed by adding these three lines to the switch statment:

case ALLEGRO_KEY_Q:
    playing = false;
    break;


Additionally, the ball and the players can go off the top or bottom of the screen, making playing the game a lot more difficult and less enjoyable.  

Also, I'm not an Allegro expert, but the game does not seem very responsive even though my machine is fast and has lots of memory.  Something is awry.

Use objects

Each of the players, the field and the ball could all be objects which could simplify some things here.  Consider transforming the code into a more object-oriented design.