Skip to content

Failure to optimize pattern to x * 8  #55714

Closed
@GabrielRavier

Description

@GabrielRavier
int r3(int n, int q)
{
	return n - q * -7;
}

This can be optimised to return (n + q * 8) - q; on architectures where n + q * 8 can be done in a single instruction (which includes x86). This transformation is done by GCC, but not by LLVM.

See also https://godbolt.org/z/4anx8846f for a Godbolt comparison

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions