[PATCH] D47144: [InstCombine] Fix PR37526: MinMax patterns produce an infinite loop.
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 08:54:13 PDT 2018
spatel added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:462-467
+ Value *NewPtr = nullptr;
+ if (auto *BC = dyn_cast<BitCastInst>(Ptr)) {
+ Value *Op0 = BC->getOperand(0);
+ if (Op0->getType()->getPointerElementType() == NewTy &&
+ Op0->getType()->getPointerAddressSpace() == AS)
+ NewPtr = Op0;
----------------
Use a matcher to simplify this?
Value *NewPtr;
if (!(match(Ptr, m_BitCast(m_Value(NewPtr))) &&
NewPtr->getType()->getPointerElementType() == NewTy &&
NewPtr->getType()->getPointerAddressSpace() == AS))
NewPtr = IC.Builder.CreateBitCast(Ptr, NewTy->getPointerTo(AS));
================
Comment at: test/Transforms/InstCombine/PR37526.ll:4-6
+%struct.x5 = type { i32 (...)**, i32, i32 }
+
+define void @repro(%struct.x5*, %struct.x5* %x12, %struct.x5* %x13) {
----------------
We shouldn't need a struct or loop to repro - something like this should be ok?
```
define void @PR37526(i32* %pz, i32* %px, i32* %py) {
%t1 = bitcast i32* %pz to i64*
%t2 = load i32, i32* %py
%t3 = load i32, i32* %px
%cmp = icmp slt i32 %t2, %t3
%select = select i1 %cmp, i32* %px, i32* %py
%bc = bitcast i32* %select to i64*
%r = load i64, i64* %bc
store i64 %r, i64* %t1
ret void
}
```
Repository:
rL LLVM
https://reviews.llvm.org/D47144
More information about the llvm-commits
mailing list