[llvm] r320513 - Revert "[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast."

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 11:12:34 PST 2017


Author: abataev
Date: Tue Dec 12 11:12:34 2017
New Revision: 320513

URL: http://llvm.org/viewvc/llvm-project?rev=320513&view=rev
Log:
Revert "[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast."

This reverts commit r320510 - again sanitizers bbots.

Removed:
    llvm/trunk/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll
Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=320513&r1=320512&r2=320513&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Tue Dec 12 11:12:34 2017
@@ -1339,39 +1339,25 @@ static bool equivalentAddressValues(Valu
 /// Converts store (bitcast (load (bitcast (select ...)))) to
 /// store (load (select ...)), where select is minmax:
 /// select ((cmp load V1, load V2), V1, V2).
-static Instruction *removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC,
-                                                        StoreInst &SI) {
+bool removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC, StoreInst &SI) {
   // bitcast?
-  if (!match(SI.getPointerOperand(), m_BitCast(m_Value())))
-    return nullptr;
+  Value *StoreAddr;
+  if (!match(SI.getPointerOperand(), m_BitCast(m_Value(StoreAddr))))
+    return false;
   // load? integer?
   Value *LoadAddr;
   if (!match(SI.getValueOperand(), m_Load(m_BitCast(m_Value(LoadAddr)))))
-    return nullptr;
+    return false;
   auto *LI = cast<LoadInst>(SI.getValueOperand());
   if (!LI->getType()->isIntegerTy())
-    return nullptr;
+    return false;
   if (!isMinMaxWithLoads(LoadAddr))
-    return nullptr;
+    return false;
 
-  if (!all_of(LI->users(), [LI, LoadAddr](User *U) {
-        auto *SI = dyn_cast<StoreInst>(U);
-        return SI && SI->getPointerOperand() != LI &&
-               peekThroughBitcast(SI->getPointerOperand()) != LoadAddr &&
-               !SI->getPointerOperand()->isSwiftError();
-      }))
-    return nullptr;
-
-  IC.Builder.SetInsertPoint(LI);
   LoadInst *NewLI = combineLoadToNewType(
       IC, *LI, LoadAddr->getType()->getPointerElementType());
-  // Replace all the stores with stores of the newly loaded value.
-  for (auto *UI : LI->users()) {
-    auto *USI = cast<StoreInst>(UI);
-    IC.Builder.SetInsertPoint(USI);
-    combineStoreToNewValue(IC, *USI, NewLI);
-  }
-  return LI;
+  combineStoreToNewValue(IC, SI, NewLI);
+  return true;
 }
 
 Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
@@ -1398,12 +1384,8 @@ Instruction *InstCombiner::visitStoreIns
   if (unpackStoreToAggregate(*this, SI))
     return eraseInstFromFunction(SI);
 
-  if (Instruction *I = removeBitcastsFromLoadStoreOnMinMax(*this, SI)) {
-    for (auto *UI : I->users())
-      eraseInstFromFunction(*cast<Instruction>(UI));
-    eraseInstFromFunction(*I);
-    return nullptr;
-  }
+  if (removeBitcastsFromLoadStoreOnMinMax(*this, SI))
+    return eraseInstFromFunction(SI);
 
   // Replace GEP indices if possible.
   if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI)) {

Removed: llvm/trunk/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll?rev=320512&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll (removed)
@@ -1,30 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S -data-layout="E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" | FileCheck %s
-
-define void @PR35618(i64* %st1, double* %st2) {
-; CHECK-LABEL: @PR35618(
-; CHECK-NEXT:    [[Y1:%.*]] = alloca double, align 8
-; CHECK-NEXT:    [[Z1:%.*]] = alloca double, align 8
-; CHECK-NEXT:    [[LD1:%.*]] = load double, double* [[Y1]], align 8
-; CHECK-NEXT:    [[LD2:%.*]] = load double, double* [[Z1]], align 8
-; CHECK-NEXT:    [[TMP10:%.*]] = fcmp olt double [[LD1]], [[LD2]]
-; CHECK-NEXT:    [[TMP121:%.*]] = select i1 [[TMP10]], double [[LD1]], double [[LD2]]
-; CHECK-NEXT:    [[TMP1:%.*]] = bitcast i64* [[ST1:%.*]] to double*
-; CHECK-NEXT:    store double [[TMP121]], double* [[TMP1]], align 8
-; CHECK-NEXT:    store double [[TMP121]], double* [[ST2:%.*]], align 8
-; CHECK-NEXT:    ret void
-;
-  %y1 = alloca double
-  %z1 = alloca double
-  %ld1 = load double, double* %y1
-  %ld2 = load double, double* %z1
-  %tmp10 = fcmp olt double %ld1, %ld2
-  %sel = select i1 %tmp10, double* %y1, double* %z1
-  %tmp11 = bitcast double* %sel to i64*
-  %tmp12 = load i64, i64* %tmp11
-  store i64 %tmp12, i64* %st1
-  %bc = bitcast double* %st2 to i64*
-  store i64 %tmp12, i64* %bc
-  ret void
-}
-




More information about the llvm-commits mailing list