Skip to content
Snippets Groups Projects
Commit be58bf98 authored by Tamar Christina's avatar Tamar Christina
Browse files

middle-end: Simplify subtract where both arguments are being bitwise inverted.

This adds a match.pd rule that drops the bitwwise nots when both arguments to a
subtract is inverted. i.e. for:

float g(float a, float b)
{
  return ~(int)a - ~(int)b;
}

we instead generate

float g(float a, float b)
{
  return (int)b - (int)a;
}

We already do a limited version of this from the fold_binary fold functions but
this makes a more general version in match.pd that applies more often.

gcc/ChangeLog:

	* match.pd: New bit_not rule.

gcc/testsuite/ChangeLog:

	* gcc.dg/subnot.c: New test.
parent c832ec4c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment