[llvm-bugs] [Bug 27236] New: Instcombine tries to create invalid IR
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 6 00:58:12 PDT 2016
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: unassignedbugs at nondot.org
Reporter: anton at korobeynikov.info
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160406/1ab8a188/attachment.html>
More information about the llvm-bugs
mailing list