[Bug tree-optimization/15826] don't use "if" to extract a single bit bit-field.
matthew.fortune at imgtec dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 20 11:37:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15826
Matthew Fortune <matthew.fortune at imgtec dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |matthew.fortune at imgtec dot com
--- Comment #17 from Matthew Fortune <matthew.fortune at imgtec dot com> ---
(In reply to Bill Schmidt from comment #15)
> ;; Function andrew (andrew, funcdef_no=2, decl_uid=2361, cgraph_uid=2,
> symbol_order=2)
>
> andrew (struct s * p)
> {
> unsigned int _4;
> unsigned int _5;
> unsigned int _6;
>
> <bb 2>:
> _4 = BIT_FIELD_REF <*p_3(D), 32, 0>;
> _5 = _4 & 1;
> _6 = _5;
> return _6;
>
> }
MIPS sees this same spurious failure. The issue (on a GCC 6 branch) is that the
optimization has successfully happened it just looks like the check is wrong in
the testcase. The presence of a logical and is not harmful as it is a
legitimate way to truncate: (from match.pd)
/* A truncation to an unsigned type (a zero-extension) should be
canonicalized as bitwise and of a mask. */
This simplification kicks in for MIPS and presumably powerpc but does not (I
don't know why) for x86_64. There is no 'goto' demonstrating that a single bit
extract does not use an IF.
I therefore propose we just update the check to verify there is no 'goto'.
Matthew
More information about the Gcc-bugs
mailing list