[PATCH] Optimize certain end of loop conditions into min/max operation

Marc Glisse marc.glisse@inria.fr
Fri Sep 18 22:09:00 GMT 2015


On Fri, 18 Sep 2015, Michael Collison wrote:

> Can you elaborate on merging the patterns using 'ext' as mentioned in your 
> post? I don't see any documentation or examples.

https://gcc.gnu.org/onlinedocs/gccint/The-Language.html
"for" lets you iterate on several variables at the same time.

For instance,

(for bitop (bit_and bit_ior)
      rbitop (bit_ior bit_and)
  (simplify
   (bitop:c (rbitop:c @0 @1) (bit_not@2 @0))
   (bitop @1 @2)))

expands to

(simplify
  (bit_and:c (bit_ior:c @0 @1) (bit_not@2 @0))
  (bit_and @1 @2))
(simplify
  (bit_ior:c (bit_and:c @0 @1) (bit_not@2 @0))
  (bit_ior @1 @2))

there are other examples using

(for cmp (eq ne)
      icmp (ne eq)

or

(for cmp (simple_comparison)
      scmp (swapped_simple_comparison)

and you can have repetitions

(for logs (LOG LOG
 	   LOG2 LOG2
 	   LOG10 LOG10)
      exps (SQRT CBRT)

(the iteration wraps around for exps).

-- 
Marc Glisse



More information about the Gcc-patches mailing list