<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Nov 15, 2013, at 3:42 PM, Kay Tiong Khoo <<a href="mailto:kkhoo@perfwizard.com">kkhoo@perfwizard.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I've been diagnosing this bug:<br><a href="http://llvm.org/bugs/show_bug.cgi?id=17827">http://llvm.org/bugs/show_bug.cgi?id=17827</a><br><br>Summary: I think the following program miscompiles at -O1 because the fact that 'f0' is a signed 3-bit value is lost in the unoptimized LLVM IR. How do we fix this?<br></div></blockquote><div><br></div><div>I don’t have the C/C++ standards in front of me but IIRC whether a char/short/int/long/long long bitfield is signed or unsigned is implementation defined. You need to explicitly specify signed or unsigned in order to have any guarantee of the signedness, e.g. signed int.</div><br><blockquote type="cite"><div dir="ltr">
<br><span style="font-family:courier new,monospace">$ cat bitfield.c</span><br><span style="font-family:courier new,monospace">/* %struct.S = type { i8, [3 x i8] } ??? */<br>struct S {<br>  int f0:3;<br>} a;<br><br>int foo (int p) {<br>
  struct S c = a;<br>  c.f0 = p & 6;<br>  return c.f0 < 1;<br>}<br><br>int main () {<br>  return foo (4);<br>}</span><br><br><br></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>