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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to