<html>
    <head>
      <base href="https://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 --- - [CodeGenPrepare] masked scatter/gather with bogus alignment causes assert"
   href="https://llvm.org/bugs/show_bug.cgi?id=26424">26424</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[CodeGenPrepare] masked scatter/gather with bogus alignment causes assert
          </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>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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm not sure who to blame for this one. In <a href="http://reviews.llvm.org/D16691">http://reviews.llvm.org/D16691</a> , I
noted that the IR verifier doesn't check for constant arg values, so maybe this
is a related problem.

In any case, I created some simple test cases for:
<a href="http://reviews.llvm.org/rL259421">http://reviews.llvm.org/rL259421</a>

The alignment parameter should be meaningless in these tests, so I just made
the value increase with each test. But when I send this IR to llc, it asserts:

$ cat gather.ll
declare <2 x double> @llvm.masked.gather.v2f64(<2 x double*> %ptrs, i32, <2 x
i1> %mask, <2 x double> %passthru)

define <2 x double> @gather_zeromask(<2 x double*> %ptrs, <2 x double>
%passthru)  {
  %res = call <2 x double> @llvm.masked.gather.v2f64(<2 x double*> %ptrs, i32
5, <2 x i1> zeroinitializer, <2 x double> %passthru)
  ret <2 x double> %res
}

$ ./llc gather.ll
Assertion failed: ((Align & (Align-1)) == 0 && "Alignment is not a power of
2!"), function setAlignment, file
/Users/spatel/myllvm/llvm/lib/IR/Instructions.cpp, line 1288.
0  llc                      0x00000001072c1d5e
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  llc                      0x00000001072c21a9
PrintStackTraceSignalHandler(void*) + 25
2  llc                      0x00000001072be949 llvm::sys::RunSignalHandlers() +
425
3  llc                      0x00000001072c2509 SignalHandler(int) + 345
4  libsystem_platform.dylib 0x00007fff9d455eaa _sigtramp + 26
5  libsystem_platform.dylib 0x00007fff6b0c98e5 _sigtramp + 3452385877
6  llc                      0x00000001072c21cb raise + 27
7  llc                      0x00000001072c2282 abort + 18
8  llc                      0x00000001072c2261 __assert_rtn + 129
9  llc                      0x0000000106ab94b2
llvm::LoadInst::setAlignment(unsigned int) + 114
10 llc                      0x000000010531cdd8 llvm::IRBuilder<true,
llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true>
<span class="quote">>::CreateAlignedLoad(llvm::Value*, unsigned int, llvm::Twine const&) + 56</span >
11 llc                      0x000000010657976e
scalarizeMaskedGather(llvm::CallInst*) + 2062
12 llc                      0x000000010656abdb (anonymous
namespace)::CodeGenPrepare::optimizeCallInst(llvm::CallInst*, bool&) + 2667
13 llc                      0x00000001065654b4 (anonymous
namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&) + 1876
14 llc                      0x0000000106563991 (anonymous
namespace)::CodeGenPrepare::optimizeBlock(llvm::BasicBlock&, bool&) + 257
15 llc                      0x0000000106561872 (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&) + 1026
16 llc                      0x0000000106af760d
llvm::FPPassManager::runOnFunction(llvm::Function&) + 413
17 llc                      0x0000000106af7945
llvm::FPPassManager::runOnModule(llvm::Module&) + 117
18 llc                      0x0000000106af869a (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&) + 2010
19 llc                      0x0000000106af7c2b
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 347
20 llc                      0x0000000106af92e1
llvm::legacy::PassManager::run(llvm::Module&) + 33
21 llc                      0x0000000104fc663c compileModule(char**,
llvm::LLVMContext&) + 19788
22 llc                      0x0000000104fc1886 main + 230
23 libdyld.dylib            0x00007fff8a4fa5ad start + 1
24 libdyld.dylib            0x0000000000000002 start + 1974491734
Stack dump:
0.    Program arguments: ./llc gather.ll 
1.    Running pass 'Function Pass Manager' on module 'gather.ll'.
2.    Running pass 'CodeGen Prepare' on function '@gather_zeromask'</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>