After

commit 62993cc9d2200ef7a05f317cdef3262996c0ac10
Author: Eikansh Gupta <[email protected]>
Date:   Thu Jul 23 17:04:17 2026 +0530

    tree-optimization: Handle variable trip count XOR in final value
replacement [PR112104]

---
extern signed char a;
signed char
func (int i, int j)
{
  signed char c = 0;
  while (i != 0)
    {
      a ^= j;
      ++c;
      ++i;
    }
  return c;
}
---

is optimized to:

testl %edi, %edi
je .L3
movl %edi, %eax
andl $1, %edi
negl %edi
negl %eax
andl %esi, %edi
xorb %dil, a(%rip)
ret
.L3:
xorl %eax, %eax
ret

add check-function-bodies to gcc.target/i386/pr92080-12.c to check for
optimized codegen.

PR tree-optimization/112104
* gcc.target/i386/pr92080-12.c: Remove scan-assembler-times and
add check-function-bodies to check for optimized codegen.

-- 
H.J.
From c0e7dc9f39235e153a519cbb4dfa8c5765d5de13 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Fri, 21 Aug 2026 12:06:13 +0800
Subject: [PATCH] x86: Adjust gcc.target/i386/pr92080-12.c

After

commit 62993cc9d2200ef7a05f317cdef3262996c0ac10
Author: Eikansh Gupta <[email protected]>
Date:   Thu Jul 23 17:04:17 2026 +0530

    tree-optimization: Handle variable trip count XOR in final value replacement [PR112104]

---
extern signed char a;
signed char
func (int i, int j)
{
  signed char c = 0;
  while (i != 0)
    {
      a ^= j;
      ++c;
      ++i;
    }
  return c;
}
---

is optimized to:

	testl	%edi, %edi
	je	.L3
	movl	%edi, %eax
	andl	$1, %edi
	negl	%edi
	negl	%eax
	andl	%esi, %edi
	xorb	%dil, a(%rip)
	ret
.L3:
	xorl	%eax, %eax
	ret

add check-function-bodies to gcc.target/i386/pr92080-12.c to check for
optimized codegen.

	PR tree-optimization/112104
	* gcc.target/i386/pr92080-12.c: Remove scan-assembler-times and
	add check-function-bodies to check for optimized codegen.

Signed-off-by: H.J. Lu <[email protected]>
---
 gcc/testsuite/gcc.target/i386/pr92080-12.c | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr92080-12.c b/gcc/testsuite/gcc.target/i386/pr92080-12.c
index cb09eb2f0a8..61630953022 100644
--- a/gcc/testsuite/gcc.target/i386/pr92080-12.c
+++ b/gcc/testsuite/gcc.target/i386/pr92080-12.c
@@ -1,6 +1,29 @@
+/* PR tree-optimization/112104  */
 /* { dg-do compile } */
 /* { dg-additional-options "-O3 -mno-mmx -march=icelake-server" } */
-/* { dg-final { scan-assembler-times "vpbroadcastb" 1 } } */
+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
+/* { dg-final { check-function-bodies "**" "" "" { target { *-*-linux* && { ! ia32 } } } {^\t?\.} } } */
+
+/*
+**f:
+**.LFB0:
+**	.cfi_startproc
+**	testl	%edi, %edi
+**	je	.L3
+**	movl	%edi, %eax
+**	andl	\$1, %edi
+**	negl	%edi
+**	negl	%eax
+**	andl	%esi, %edi
+**	xorb	%dil, a\(%rip\)
+**	ret
+**...
+**.L3:
+**	xorl	%eax, %eax
+**	ret
+**	.cfi_endproc
+**...
+*/
 
 signed char a;
 signed char f (int i, int j)
-- 
2.55.0

Reply via email to