[Bug middle-end/33887] [4.2/4.3 Regression] Reference to bitfield gets wrong value when optimizing
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Dec 11 12:38:00 GMT 2007
------- Comment #6 from rguenth at gcc dot gnu dot org 2007-12-11 12:38 -------
In reply to comment #3:
no,
int f2 = sv.f2;
does _not_ sign extend. 4.7/3 says "If the destination type is signed, the
value is unchanged if it can be represented in the destination type...".
Note your bitfield is unsigned.
Instead the error is with
++sv.f2;
f2 = sv.f2;
fn(f2, 0);
which should result in zero (as tested). But we expand the above to
;; D.2041 = sv.f2 + 1
(insn 20 17 21 t.ii:27 (set (reg/f:DI 71)
(const:DI (plus:DI (symbol_ref:DI ("sv") [flags 0x2] <var_decl
0x2b1ba3468140 sv>)
(const_int 4 [0x4])))) -1 (nil))
(insn 21 20 22 t.ii:27 (set (reg:SI 73)
(mem/s/c:SI (reg/f:DI 71) [0+4 S4 A32])) -1 (nil))
(insn 22 21 23 t.ii:27 (parallel [
(set (reg:SI 72)
(lshiftrt:SI (reg:SI 73)
(const_int 8 [0x8])))
(clobber (reg:CC 17 flags))
]) -1 (expr_list:REG_EQUAL (lshiftrt:SI (mem/s/c:SI (reg/f:DI 71) [0+4
S4 A32])
(const_int 8 [0x8]))
(nil)))
(insn 23 22 0 t.ii:27 (parallel [
(set (reg:SI 58 [ D.2041 ])
(plus:SI (reg:SI 72)
(const_int 1 [0x1])))
(clobber (reg:CC 17 flags))
]) -1 (nil))
;; sv.f2 = D.2041
(insn 25 23 26 t.ii:27 (set (reg/f:DI 75)
(const:DI (plus:DI (symbol_ref:DI ("sv") [flags 0x2] <var_decl
0x2b1ba3468140 sv>)
(const_int 4 [0x4])))) -1 (nil))
(insn 26 25 27 t.ii:27 (parallel [
(set (reg:SI 76)
(ashift:SI (reg:SI 58 [ D.2041 ])
(const_int 8 [0x8])))
(clobber (reg:CC 17 flags))
]) -1 (nil))
(insn 27 26 28 t.ii:27 (set (reg:SI 77)
(mem/s/j/c:SI (reg/f:DI 75) [0+4 S4 A32])) -1 (nil))
(insn 28 27 29 t.ii:27 (parallel [
(set (reg:SI 78)
(and:SI (reg:SI 77)
(const_int 255 [0xff])))
(clobber (reg:CC 17 flags))
]) -1 (nil))
(insn 29 28 30 t.ii:27 (parallel [
(set (reg:SI 79)
(ior:SI (reg:SI 78)
(reg:SI 76)))
(clobber (reg:CC 17 flags))
]) -1 (nil))
(insn 30 29 0 t.ii:27 (set (mem/s/j/c:SI (reg/f:DI 75) [0+4 S4 A32])
(reg:SI 79)) -1 (nil))
;; fn ((int) D.2041, 0)
(insn 31 30 32 t.ii:29 (set (reg:SI 4 si)
(const_int 0 [0x0])) -1 (nil))
(insn 32 31 33 t.ii:29 (set (reg:SI 5 di)
(reg:SI 58 [ D.2041 ])) -1 (nil))
(call_insn 33 32 0 t.ii:29 (call (mem:QI (symbol_ref/i:DI ("_Z2fnIiiEvT_T0_")
[flags 0x1] <function_decl 0x2b1ba3461820 fn>) [0 S1 A8])
...
because reg:SI 58 is not a properly truncated intermediate result.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33887
More information about the Gcc-bugs
mailing list