[LLVMbugs] [Bug 19737] New: Assertion failure about type casting BinaryOperator when reordering shuffle and binary operation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 13 23:13:29 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19737

            Bug ID: 19737
           Summary: Assertion failure about type casting BinaryOperator
                    when  reordering shuffle and binary operation
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: Hao.Liu at arm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This bug is related to 19717 and 19730.
The CreateBinOpAsGiven() assumes that CreateBinOp will return a BinaryOperator
type. But when two operands are Constant, it may optimize the result and just
return a Constant. As a result, there is a type cast assertion failure.
To reproduce with following case test.ll:
---------------------------------------------------------------------------------
define i32 @test(<4 x i32> %in0) {
entry:
  %shuffle.i = shufflevector <4 x i32> zeroinitializer, <4 x i32> %in0, <4 x
i32> <i32 0, i32 4, i32 2, i32 6>
  %neg.i = xor <4 x i32> %shuffle.i, <i32 -1, i32 -1, i32 -1, i32 -1>
  %and.i = and <4 x i32> %in0, %neg.i
  %0 = extractelement <4 x i32> %and.i, i32 0
  ret i32 %0
}
---------------------------------------------------------------------------------

To run as following:
$ opt -S -instcombine test.ll
opt: llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X,
Y*>::ret_type llvm::cast(Y*) [with X = llvm::BinaryOperator; Y = llvm::Value;
typename llvm::cast_retty<X, Y*>::ret_type = llvm::BinaryOperator*]: Assertion
`isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Note that not only XOR, creating other binary operation may also result into
Constant type instead of a BinaryOperator.

Thanks,
-Hao

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140514/76cb7c4b/attachment.html>


More information about the llvm-bugs mailing list