<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 --- - Loop Vectorizer strips address space id when generating a bitcast to/from a vector type"
   href="http://llvm.org/bugs/show_bug.cgi?id=16306">16306</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop Vectorizer strips address space id when generating a bitcast to/from a vector type
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pekka.jaaskelainen@tut.fi
          </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>$ cat copy.c
char Y[4*10000] __attribute__((address_space(1)));
char X[4*10000];

int main() {
    for (int i = 0; i < 4*10000; ++i)
        X[i] = Y[i] + 1;
    return 0;
}

$ clang -O3 copy.c -S -emit-llvm -c -O3 -o  -
...
define i32 @main() #0 {
vector.ph:
  br label %vector.body

vector.body:                                      ; preds = %vector.body,
%vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %0 = getelementptr inbounds [40000 x i8] addrspace(1)* @Y, i64 0, i64 %index
  %1 = bitcast i8 addrspace(1)* %0 to <16 x i8>*
  %wide.load = load <16 x i8>* %1, align 16
  %.sum13 = or i64 %index, 16
  %2 = getelementptr [40000 x i8] addrspace(1)* @Y, i64 0, i64 %.sum13
  %3 = bitcast i8 addrspace(1)* %2 to <16 x i8>*
;                                     ^-------------- breaks here


  %wide.load10 = load <16 x i8>* %3, align 16
  %4 = add <16 x i8> %wide.load, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8
1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %5 = add <16 x i8> %wide.load10, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1,
i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %6 = getelementptr inbounds [40000 x i8]* @X, i64 0, i64 %index
  %7 = bitcast i8* %6 to <16 x i8>*
  store <16 x i8> %4, <16 x i8>* %7, align 16
  %.sum14 = or i64 %index, 16
  %8 = getelementptr [40000 x i8]* @X, i64 0, i64 %.sum14
  %9 = bitcast i8* %8 to <16 x i8>*
  store <16 x i8> %5, <16 x i8>* %9, align 16
  %index.next = add i64 %index, 32
  %10 = icmp eq i64 %index.next, 40000
  br i1 %10, label %for.end, label %vector.body

for.end:                                          ; preds = %vector.body
  ret i32 0
}
...

Is there a nice trick to disable loop vectorizer at the opt command line when
-O3 is used?</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>