https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66703
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |WONTFIX
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
We have
unsigned int
readeflags_test (unsigned int a, unsigned int b)
{
unsigned x = (a == b);
return __builtin_ia32_readeflags_u32 ();
}
For
unsigned x = (a == b);
-march=i586 generates:
;; _3 = a_1(D) == b_2(D);
(insn 5 4 6 (set (reg:SI 90)
(mem/c:SI (reg/f:SI 81 virtual-incoming-args) [0 a+0 S4 A32])) y.i:4 -1
(nil))
(insn 6 5 7 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 90)
(mem/c:SI (plus:SI (reg/f:SI 81 virtual-incoming-args)
(const_int 4 [0x4])) [0 b+0 S4 A32]))) y.i:4 -1
(nil))
(insn 7 6 0 (set (reg:QI 87 [ D.1413 ])
(eq:QI (reg:CCZ 17 flags)
(const_int 0 [0]))) y.i:4 -1
(nil))
;; x_4 = (unsigned int) _3;
(insn 8 7 9 (parallel [
(set (reg:SI 91)
(zero_extend:SI (reg:QI 87 [ D.1413 ])))
(clobber (reg:CC 17 flags))
]) y.i:4 -1
(nil))
(insn 9 8 0 (set (mem/c:SI (plus:SI (reg/f:SI 82 virtual-stack-vars)
(const_int -4 [0xfffffffffffffffc])) [0 x+0 S4 A32])
(reg:SI 91)) y.i:4 -1
(nil))
EFLAGS register is clobbered and __builtin_ia32_readeflags_u32
returns clobbered value. So the testcase is expected to fail
if zero-extend bool to unsigned int clobbers EFLAGS register. Since
we have
/* X86_TUNE_ZERO_EXTEND_WITH_AND: Use AND instruction instead
of mozbl/movwl. */
DEF_TUNE (X86_TUNE_ZERO_EXTEND_WITH_AND, "zero_extend_with_and",
m_486 | m_PENT)
This test should fail with -march=i486, -march=i586 or -miamcu.