<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - llvm.smul.fix.sat.i8(-128, -128, 0) equals -128"
   href="https://bugs.llvm.org/show_bug.cgi?id=51677">51677</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm.smul.fix.sat.i8(-128, -128, 0) equals -128
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>twostepted@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The result of this operation should be 127.  
This was confirmed in irc
<span class="quote">> <LebedevRI> for scale=0, i would still say this is a bug</span >



$ cat test.ll

; test.ll - smul.fix.sat i8min * i8min should == i8max
define i8 @main() {
entry:
    %res = call i8 @llvm.smul.fix.sat.i8(i8 -128, i8 -128, i32 0)
    %x = sub i8 %res, 127
    ret i8 %x
}

declare i8 @llvm.smul.fix.sat.i8(i8, i8, i32)

$ lli-12 test.ll
$ echo $?
1
$ cat test2.ll

; test2.ll - smul.fix.sat i8max * i8max should == i8max
define i8 @main() {
entry:
    %res = call i8 @llvm.smul.fix.sat.i8(i8 127, i8 127, i32 0)

    %x = sub i8 %res, 127
    ret i8 %x
}

declare i8 @llvm.smul.fix.sat.i8(i8, i8, i32)

$ lli-12 test2.ll
$ echo $?
1



So it seems like there is a signedness error when dealing with signed type
maximums and minimums.  I observed the same using i128.  This doesn't seem to
happend with the unsigned umul.fix.sat intrinsics.

The same results were observed using trunk.  

Not sure i've chosen the correct component 'Common Code Generator Code' in the
drop-down above.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>