Retailers have for years toyed with technology to automate anything from warehouses to check out, in hopes of saving money, space and time. Amazon has been perfecting its AmazonGo, stores without checkout lines or cashiers, and Walmart is testing similar technology, through its start-up incubator, Store No. 8, according to Recode .

Up to 7.5 million retail industry jobs are vulnerable to automation within 10 years, the Cornerstone Capital Group wrote in May.

Under the Tax Cuts and Jobs Act , which President Donald Trump signed into law on Friday, the effective cost of buying new equipment will drop and savings from reducing payroll costs could jump by at least 20 percent. In other words: Buying labor-replacing machinery may be cheaper and firing employees may save more money.

The cashier may be automated faster thanks to the tax bill.

The investments required for automation, though, can be steep and the returns are not always offset by short-term labor savings.

The math could change under the new tax law.

Under the law, companies will now be able to write off the cost of new equipment immediately rather than over an extended time, thereby lowering their short-term taxes. Because money is worth more now than in the future (the time value of money), they will save more in the long run from deductions than they would have previously. With this provision set to begin to phase out in five years, retailers looking to automate are under the gun.

"If prices of equipment don't change, you might see companies accelerate plans to buy equipment they were already thinking about buying," said Corey Goodman, a partner in the tax department of law firm Cleary Gottlieb Steen & Hamilton.

"If a company is planning on investing in equipment, the tax savings will be greater doing it sooner rather than later."

Meanwhile, as the corporate tax rate drops from 35 percent to 21 percent, companies can keep a greater share of their income. That also means they can pocket more savings achieved through cost cutting, like laying off workers.

Broken down: If a retailer saves $100 in wages and benefits by laying off an employee in 2017, its after-tax savings is $65 ($100 savings less $35 paid in taxes). If it does the same in 2018, its after-tax benefit is $79 ($100 in savings less $21 paid in taxes).

A retailer thus pockets $14 more from laying off a worker in 2018 than in 2017, a jump of more than 20 percent.

Retail trade groups have, by and large, supported the legislation.

The National Retail Federation called it "a major victory" that will "jumpstart the economy, encourage companies to invest here in the United States, increase wages and expand opportunities for employees."

The National Grocers Association has commended it as a "weight lifted off [its] shoulders [that] will allow stores to invest more in their companies, employees, and communities."

To be sure, any company considering layoffs or buying new technology will weigh multiple and moving variables before doing so. The math itself is subject to changes: Manufacturing companies could simply charge retailers more, and retailers could charge their customer less, thereby dampening savings from automation. These considerations extend to industries beyond retail.

But retailers are in a particularly perilous time: rising minimum wages, changes in shopping behavior and an omnipresent Amazon. They are furiously trying to steady their cost structure, including by making stores smaller and more profitable.

"Any time there's a change in a price of a product, people's calculations about what they want to buy will change," said Goodman.