<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 1/3/2017 2:28 PM, via cfe-dev wrote:<br>
    </div>
    <blockquote
      cite="mid:1139060582.6974289.1483482483677@mail.yahoo.com"
      type="cite"><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->
      <div style="color:#000; background-color:#fff; font-family:lucida
        console, sans-serif;font-size:13px">Hi clang devs,
        <div id="yui_3_16_0_ym19_1_1483447542855_7226"><br
            id="yui_3_16_0_ym19_1_1483447542855_7227">
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7228">I was looking at
          PR9350 and saw that Eli added a test to check LLVM doesn't
          overflow on [signed] char increment:</div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7229"><br
            id="yui_3_16_0_ym19_1_1483447542855_7230">
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7231" dir="ltr">---
          cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:43:30
          126815<br id="yui_3_16_0_ym19_1_1483447542855_7232">
          +++ cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02
          01:49:12 126816<br id="yui_3_16_0_ym19_1_1483447542855_7233">
          @@ -50,11 +50,17 @@<br
            id="yui_3_16_0_ym19_1_1483447542855_7234">
             // TRAPV_HANDLER: foo(<br
            id="yui_3_16_0_ym19_1_1483447542855_7235">
             --a;<br id="yui_3_16_0_ym19_1_1483447542855_7236">
             <br id="yui_3_16_0_ym19_1_1483447542855_7237">
          -  <br id="yui_3_16_0_ym19_1_1483447542855_7238">
             // -fwrapv should turn off inbounds for GEP's, PR9256<br
            id="yui_3_16_0_ym19_1_1483447542855_7239">
             extern int* P;<br id="yui_3_16_0_ym19_1_1483447542855_7240">
             ++P;<br id="yui_3_16_0_ym19_1_1483447542855_7241">
             // DEFAULT: getelementptr inbounds i32*<br
            id="yui_3_16_0_ym19_1_1483447542855_7242">
             // WRAPV: getelementptr i32*<br
            id="yui_3_16_0_ym19_1_1483447542855_7243">
             // TRAPV: getelementptr inbounds i32*<br
            id="yui_3_16_0_ym19_1_1483447542855_7244">
          +<br id="yui_3_16_0_ym19_1_1483447542855_7245">
          +  // PR9350: char increment never overflows.<br
            id="yui_3_16_0_ym19_1_1483447542855_7246">
          +  extern volatile signed char PR9350;<br
            id="yui_3_16_0_ym19_1_1483447542855_7247">
          +  // DEFAULT: add i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7248">
          +  // WRAPV: add i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7249">
          +  // TRAPV: add i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7250">
          +  ++PR9350;<br id="yui_3_16_0_ym19_1_1483447542855_7251">
          }</div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7252" dir="ltr"><br>
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7798" dir="ltr"><a
            moz-do-not-send="true"
            id="yui_3_16_0_ym19_1_1483447542855_7797"
href="http://llvm.org/viewvc/llvm-project?view=revision&revision=126816">http://llvm.org/viewvc/llvm-project?view=revision&revision=126816</a></div>
        <div id="yui_3_16_0_ym19_1_1483447542855_8228" dir="ltr"><br
            id="yui_3_16_0_ym19_1_1483447542855_7253">
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7254" dir="ltr">Presumably
          the logic about promotion to int applies the same as in the
          argument John gave in PR9350 since 6.5.3.1 §3 says "the prefix
          -- operator is analogous to the prefix ++ operator, except
          that the value of the operand is decremented".</div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7255" dir="ltr"><br
            id="yui_3_16_0_ym19_1_1483447542855_7256">
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7257" dir="ltr">Would
          it therefore make sense to add the equivalent test to
          integer-overflow.c that decrement of a [signed] char didn't
          ever cause underflow:</div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7258" dir="ltr"><br
            id="yui_3_16_0_ym19_1_1483447542855_7259">
        </div>
        <div id="yui_3_16_0_ym19_1_1483447542855_7260" dir="ltr">  //
          DEFAULT: sub i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7261">
            // WRAPV: sub i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7262">
            // TRAPV: sub i8 {{.*}}, 1<br
            id="yui_3_16_0_ym19_1_1483447542855_7263">
            --PR9350;<br id="yui_3_16_0_ym19_1_1483447542855_7264">
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    Yes, it probably makes sense to add a testcase like that.  Patch
    welcome.<br>
    <p>-Eli<br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </body>
</html>