[PATCH GCC][1/4]Simplify (convert1 (minmax ((convert2 (x) c)))) into minmax (x c)

Bin Cheng Bin.Cheng@arm.com
Tue Oct 25 11:21:00 GMT 2016


Hi,
This is a patch set adding various match.pd patterns in order to generate simplified MIN/MAX_EXPR mostly from COND_EXPR.  This is the first one optimizing (convert1 (minmax ((convert2 (x) c)))) to minmax (x c), if convert2 promotes x and convert1 demotes back to x's type.  With this patch, generated assembly for test:
.L4:
	ldr	q0, [x3, x1]
	add	w2, w2, 1
	cmp	w0, w2
	ushll	v2.4s, v0.4h, 0
	ushll2	v1.4s, v0.8h, 0
	umin	v2.4s, v2.4s, v3.4s
	umin	v1.4s, v1.4s, v3.4s
	xtn	v4.4h, v2.4s
	xtn2	v4.8h, v1.4s
	str	q4, [x3, x1]
	add	x1, x1, 16
	bhi	.L4

can be improved to:
.L4:
	ldr	q0, [x3, x1]
	add	w2, w2, 1
	cmp	w0, w2
	umin	v1.8h, v0.8h, v2.8h
	str	q1, [x3, x1]
	add	x1, x1, 16
	bhi	.L4

Bootstrap and test on x86_64 and AArch64 for whole patch set.  Is it OK?

Thanks,
bin

2016-10-21  Bin Cheng  <bin.cheng@arm.com>

	* match.pd ((convert1 (minmax ((convert2 (x) c)))) -> minmax (x c)):
	New pattern.

gcc/testsuite/ChangeLog
2016-10-21  Bin Cheng  <bin.cheng@arm.com>

	* gcc.dg/fold-convmaxconv-1.c: New test.
	* gcc.dg/fold-convminconv-1.c: New test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 01-simplify-convminmaxconv-20161020.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161025/da5ed858/attachment.txt>


More information about the Gcc-patches mailing list