<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - [NVPTX] llc error on select with llvm.ptx.read.* TargetConstant"
   href="http://llvm.org/bugs/show_bug.cgi?id=22322">22322</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[NVPTX] llc error on select with llvm.ptx.read.* TargetConstant
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: PTX
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>justin.holewinski@gmail.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>florian.ziesche+llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13728" name="attach_13728" title="the error producing .ll file">attachment 13728</a> <a href="attachment.cgi?id=13728&action=edit" title="the error producing .ll file">[details]</a></span>
the error producing .ll file

when compiling the attached .ll or .cpp file to ptx, llc errors with:
LLVM ERROR: Cannot select: 0x1a61188: i1 = setcc 0x1a60d68, 0x1a60b58,
0x1a61080 [ORD=15] [ID=30]
  0x1a60d68: f32 = select 0x1a60a50, 0x1a60b58, 0x1a60c60 [ORD=13] [ID=27]
    0x1a60a50: i1 = setcc 0x1a60738, 0x1a60840, 0x1a60948 [ORD=12] [ID=25]
      0x1a60738: i32 = and 0x1a5f358, 0x1a60630 [ORD=11] [ID=23]
        0x1a5f358: i32 = NVPTXISD::IMAD 0x1a5ee30, 0x1a5ec20, 0x1a5f148 [ORD=7]
[ID=22]
          0x1a5ee30: i32 = llvm.ptx.read.ntid.x 0x1a5ed28 [ORD=4] [ID=19]
            0x1a5ed28: i64 = TargetConstant<3016> [ID=4]
          0x1a5ec20: i32 = llvm.ptx.read.ctaid.x 0x1a5eb18 [ORD=3] [ID=18]
            0x1a5eb18: i64 = TargetConstant<3000> [ID=3]
          0x1a5f148: i32 = llvm.ptx.read.tid.x 0x1a5f040 [ORD=6] [ID=20]
            0x1a5f040: i64 = TargetConstant<3026> [ID=5]
        0x1a60630: i32 = Constant<15> [ID=8]
      0x1a60840: i32 = Constant<0> [ID=9]
    0x1a60b58: f32 = ConstantFP<0.000000e+00> [ID=11]
    0x1a60c60: f32 = ConstantFP<-1.000000e+00> [ID=12]
  0x1a60b58: f32 = ConstantFP<0.000000e+00> [ID=11]
In function: some_kernel


Steps to Reproduce:
using the .ll file: cat ptx_select_error.ll | llc -mcpu=sm_30
using the .cpp file: clang++ -x cuda -std=cuda -target nvptx64-nvidia-cuda
-Xclang -fcuda-is-device -Ofast -emit-llvm -S -o - ptx_select_error.cpp | llc
-mcpu=sm_30


some notes:
* neither the sm_xx target nor the bitness matter here
* I've confirmed this bug with clang/llvm 3.5.0 on OS X, 3.5.1 on Linux and 3.6
rc1 on OS X
* compiling the .cpp file in any other -O mode than -Ofast results in an .ll
file that llc has no problems with (then again, even with -O3 it's about twice
as long and there are still branch instructions)
* the problematic select instruction is "%9 = select i1 %8, float 0.000000e+00,
float -1.000000e+00"</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>