https://llvm.org/bugs/show_bug.cgi?id=27236
Bug ID: 27236 Summary: Instcombine tries to create invalid IR Product: libraries Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: an...@korobeynikov.info CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16174 --> https://llvm.org/bugs/attachment.cgi?id=16174&action=edit Testcase Consider the attached IR. opt -instcombine -debug yields: IC: Replacing %.sroa.4.0 = select i1 %4, float %3, float 0.000000e+00 with %2 = select i1 %1, i32 1, i32 %0 Assertion failed: (New->getType() == getType() && "replaceAllUses of value with new value of different type!"), function replaceAllUsesWith, file /Users/asl/Projects/llvm/2commit/llvm/lib/IR/Value.cpp, line 375. Which is certainly incorrect. I believe the problem was exposed by the recent changes in min/max optimizations and min(min) / max(max) folding. The "big hammer" fix is to have something like this: Index: lib/Transforms/InstCombine/InstCombineSelect.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineSelect.cpp (revision 265487) +++ lib/Transforms/InstCombine/InstCombineSelect.cpp (working copy) @@ -642,6 +642,9 @@ Value *A, Value *B, Instruction &Outer, SelectPatternFlavor SPF2, Value *C) { + if (Outer.getType() != Inner->getType()) + return nullptr; + if (C == A || C == B) { // MAX(MAX(A, B), B) -> MAX(A, B) // MIN(MIN(a, b), a) -> MIN(a, b) However, I believe we need to make sure we never call stuff this way -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs