[llvm-branch-commits] [clang] b41b743 - [test] Improve weakref & weak_import tests

2021-01-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-09T23:56:55-08:00
New Revision: b41b743d461168300ae0121937b50e334563d307

URL: 
https://github.com/llvm/llvm-project/commit/b41b743d461168300ae0121937b50e334563d307
DIFF: 
https://github.com/llvm/llvm-project/commit/b41b743d461168300ae0121937b50e334563d307.diff

LOG: [test] Improve weakref & weak_import tests

Added: 


Modified: 
clang/test/CodeGen/attr-weak-import.c
clang/test/CodeGen/attr-weakref.c
clang/test/CodeGen/attr-weakref2.c

Removed: 




diff  --git a/clang/test/CodeGen/attr-weak-import.c 
b/clang/test/CodeGen/attr-weak-import.c
index 23d02c10dca1..85989f03a277 100644
--- a/clang/test/CodeGen/attr-weak-import.c
+++ b/clang/test/CodeGen/attr-weak-import.c
@@ -18,9 +18,9 @@ extern int E __attribute__((weak_import));
 int E;
 extern int E __attribute__((weak_import));
 
-// CHECK: @A ={{.*}} global i32
+// CHECK: @A = dso_local global i32
 // CHECK-NOT: @B =
-// CHECK: @C ={{.*}} global i32
-// CHECK: @D ={{.*}} global i32
-// CHECK: @E ={{.*}} global i32
+// CHECK: @C = dso_local global i32
+// CHECK: @D = dso_local global i32
+// CHECK: @E = dso_local global i32
 

diff  --git a/clang/test/CodeGen/attr-weakref.c 
b/clang/test/CodeGen/attr-weakref.c
index 0923cf33a6de..7ed4efdd2cb4 100644
--- a/clang/test/CodeGen/attr-weakref.c
+++ b/clang/test/CodeGen/attr-weakref.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o - %s | FileCheck %s
 
 // CHECK: declare extern_weak void @test1_f()
 void test1_f(void);
@@ -8,7 +7,7 @@ void test1_h(void) {
   test1_g();
 }
 
-// CHECK-LABEL: define{{.*}} void @test2_f()
+// CHECK-LABEL: define dso_local void @test2_f()
 void test2_f(void) {}
 static void test2_g(void) __attribute__((weakref("test2_f")));
 void test2_h(void) {
@@ -25,7 +24,7 @@ void test3_h(void) {
   test3_g();
 }
 
-// CHECK-LABEL: define{{.*}} void @test4_f()
+// CHECK-LABEL: define dso_local void @test4_f()
 void test4_f(void);
 static void test4_g(void) __attribute__((weakref("test4_f")));
 void test4_h(void) {

diff  --git a/clang/test/CodeGen/attr-weakref2.c 
b/clang/test/CodeGen/attr-weakref2.c
index 47c96fd5af41..2746819833b1 100644
--- a/clang/test/CodeGen/attr-weakref2.c
+++ b/clang/test/CodeGen/attr-weakref2.c
@@ -8,7 +8,7 @@ int test1_h(void) {
   return test1_g;
 }
 
-// CHECK: @test2_f ={{.*}} global i32 0, align 4
+// CHECK: @test2_f = dso_local global i32 0, align 4
 int test2_f;
 static int test2_g __attribute__((weakref("test2_f")));
 int test2_h(void) {
@@ -25,7 +25,7 @@ int test3_h(void) {
   return test3_g;
 }
 
-// CHECK: @test4_f ={{.*}} global i32 0, align 4
+// CHECK: @test4_f = dso_local global i32 0, align 4
 extern int test4_f;
 static int test4_g __attribute__((weakref("test4_f")));
 int test4_h(void) {



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 9f2d936 - [CodeGen] Update transformations to use poison for shufflevector/insertelem's initial vector elem

2021-01-10 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2021-01-10T18:03:51+09:00
New Revision: 9f2d9364b04c4d9651b1ec8612a3968b969fe71d

URL: 
https://github.com/llvm/llvm-project/commit/9f2d9364b04c4d9651b1ec8612a3968b969fe71d
DIFF: 
https://github.com/llvm/llvm-project/commit/9f2d9364b04c4d9651b1ec8612a3968b969fe71d.diff

LOG: [CodeGen] Update transformations to use poison for 
shufflevector/insertelem's initial vector elem

This patch is a part of D93817 and makes transformations in CodeGen use poison 
for shufflevector/insertelem's initial vector element.

The change in CodeGenPrepare.cpp is fine because the mask of shufflevector 
should be always zero.
It doesn't touch the second element (which is poison).

The change in InterleavedAccessPass.cpp is also fine becauses the mask is of 
the form  where a+km is smaller than
the size of the first vector operand.
This is guaranteed by the caller of replaceBinOpShuffles, which is 
lowerInterleavedLoad.
It calls isDeInterleaveMask and isDeInterleaveMaskOfFactor to check the mask is 
the desirable form.
isDeInterleaveMask has the check that a+km is smaller than the vector size.
To check my understanding, I added an assertion & added a test to show that 
this optimization doesn't fire in such case.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D94056

Added: 


Modified: 
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/InterleavedAccessPass.cpp

llvm/test/Transforms/InterleavedAccess/X86/interleave-load-extract-shuffle-changes.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index c621cef8024e..85371d0d5d31 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6699,6 +6699,7 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
 /// in MVE takes a GPR (integer) register, and the instruction that incorporate
 /// a VDUP (such as a VADD qd, qm, rm) also require a gpr register.
 bool CodeGenPrepare::optimizeShuffleVectorInst(ShuffleVectorInst *SVI) {
+  // Accept shuf(insertelem(undef/poison, val, 0), undef/poison, <0,0,..>) only
   if (!match(SVI, m_Shuffle(m_InsertElt(m_Undef(), m_Value(), m_ZeroInt()),
 m_Undef(), m_ZeroMask(
 return false;
@@ -6718,9 +6719,7 @@ bool 
CodeGenPrepare::optimizeShuffleVectorInst(ShuffleVectorInst *SVI) {
   Builder.SetInsertPoint(SVI);
   Value *BC1 = Builder.CreateBitCast(
   cast(SVI->getOperand(0))->getOperand(1), NewType);
-  Value *Insert = Builder.CreateInsertElement(UndefValue::get(NewVecType), BC1,
-  (uint64_t)0);
-  Value *Shuffle = Builder.CreateShuffleVector(Insert, SVI->getShuffleMask());
+  Value *Shuffle = Builder.CreateVectorSplat(NewVecType->getNumElements(), 
BC1);
   Value *BC2 = Builder.CreateBitCast(Shuffle, SVIVecType);
 
   SVI->replaceAllUsesWith(BC2);

diff  --git a/llvm/lib/CodeGen/InterleavedAccessPass.cpp 
b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
index 6e1621450755..b22e6faeb91c 100644
--- a/llvm/lib/CodeGen/InterleavedAccessPass.cpp
+++ b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
@@ -22,8 +22,8 @@
 //
 // E.g. An interleaved load (Factor = 2):
 //%wide.vec = load <8 x i32>, <8 x i32>* %ptr
-//%v0 = shuffle <8 x i32> %wide.vec, <8 x i32> undef, <0, 2, 4, 6>
-//%v1 = shuffle <8 x i32> %wide.vec, <8 x i32> undef, <1, 3, 5, 7>
+//%v0 = shuffle <8 x i32> %wide.vec, <8 x i32> poison, <0, 2, 4, 6>
+//%v1 = shuffle <8 x i32> %wide.vec, <8 x i32> poison, <1, 3, 5, 7>
 //
 // It could be transformed into a ld2 intrinsic in AArch64 backend or a vld2
 // intrinsic in ARM backend.
@@ -351,6 +351,7 @@ bool InterleavedAccess::lowerInterleavedLoad(
 Index))
   return false;
 
+assert(Shuffle->getShuffleMask().size() <= NumLoadElements);
 Indices.push_back(Index);
   }
   for (auto *Shuffle : BinOpShuffles) {
@@ -360,6 +361,8 @@ bool InterleavedAccess::lowerInterleavedLoad(
 Index))
   return false;
 
+assert(Shuffle->getShuffleMask().size() <= NumLoadElements);
+
 if (cast(Shuffle->getOperand(0))->getOperand(0) == LI)
   Indices.push_back(Index);
 if (cast(Shuffle->getOperand(0))->getOperand(1) == LI)
@@ -394,13 +397,17 @@ bool InterleavedAccess::replaceBinOpShuffles(
 SmallVectorImpl &Shuffles, LoadInst *LI) {
   for (auto *SVI : BinOpShuffles) {
 BinaryOperator *BI = cast(SVI->getOperand(0));
+Type *BIOp0Ty = BI->getOperand(0)->getType();
 ArrayRef Mask = SVI->getShuffleMask();
+assert(all_of(Mask, [&](int Idx) {
+  return Idx < (int)cast(BIOp0Ty)->getNumElements();
+}));
 
-auto *NewSVI1 = new ShuffleVectorInst(
-BI->getOperand(0), UndefValue::get(BI->getOperand(0)->getType()), Mask,
-SVI->getName(), SVI);
+auto *NewSVI1 =
+  

[llvm-branch-commits] [mlir] a922486 - [mlir] NFC - Drop spurious assertion on symbols during `promoteComposedSymbolsAsDims`

2021-01-10 Thread Nicolas Vasilache via llvm-branch-commits

Author: Nicolas Vasilache
Date: 2021-01-10T14:02:16Z
New Revision: a92248600ec4acba00db566a54c8ce53de807e3c

URL: 
https://github.com/llvm/llvm-project/commit/a92248600ec4acba00db566a54c8ce53de807e3c
DIFF: 
https://github.com/llvm/llvm-project/commit/a92248600ec4acba00db566a54c8ce53de807e3c.diff

LOG: [mlir] NFC - Drop spurious assertion on symbols during 
`promoteComposedSymbolsAsDims`

This assertion is an old remnant from earlier days when only affine functions 
existed.
It is not the place of affine map composition to check whether orthogonal 
considerations
on what is allowed to be a symbol under the AffineScope trait.

Added: 


Modified: 
mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 3fd1b62a5d2d..2e75cd07ed83 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -635,12 +635,6 @@ static AffineMap promoteComposedSymbolsAsDims(AffineMap 
map,
 return map;
   }
 
-  // Sanity check on symbols.
-  for (auto sym : symbols) {
-assert(isValidSymbol(sym) && "Expected only valid symbols");
-(void)sym;
-  }
-
   // Extract the symbol positions that come from an AffineApplyOp and
   // needs to be rewritten as dims.
   auto symPositions = indicesFromAffineApplyOp(symbols);
@@ -2401,8 +2395,7 @@ LogicalResult AffineStoreOp::fold(ArrayRef 
cstOperands,
 // AffineMinMaxOpBase
 
//===--===//
 
-template 
-static LogicalResult verifyAffineMinMaxOp(T op) {
+template  static LogicalResult verifyAffineMinMaxOp(T op) {
   // Verify that operand count matches affine map dimension and symbol count.
   if (op.getNumOperands() != op.map().getNumDims() + op.map().getNumSymbols())
 return op.emitOpError(
@@ -2410,8 +2403,7 @@ static LogicalResult verifyAffineMinMaxOp(T op) {
   return success();
 }
 
-template 
-static void printAffineMinMaxOp(OpAsmPrinter &p, T op) {
+template  static void printAffineMinMaxOp(OpAsmPrinter &p, T op) {
   p << op.getOperationName() << ' ' << op->getAttr(T::getMapAttrName());
   auto operands = op.getOperands();
   unsigned numDims = op.map().getNumDims();



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 47991a1 - [lld/mac] llvm style fix: no else after return

2021-01-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2021-01-10T09:35:00-05:00
New Revision: 47991a15d1925cba4687c5077cc9c81c8fcd00bd

URL: 
https://github.com/llvm/llvm-project/commit/47991a15d1925cba4687c5077cc9c81c8fcd00bd
DIFF: 
https://github.com/llvm/llvm-project/commit/47991a15d1925cba4687c5077cc9c81c8fcd00bd.diff

LOG: [lld/mac] llvm style fix: no else after return

Added: 


Modified: 
lld/MachO/Writer.cpp

Removed: 




diff  --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 53267c072c59..bdc3609e033d 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -557,7 +557,8 @@ static int sectionOrder(OutputSection *osec) {
 .Case(section_names::unwindInfo, std::numeric_limits::max() - 1)
 .Case(section_names::ehFrame, std::numeric_limits::max())
 .Default(0);
-  } else if (segname == segment_names::data) {
+  }
+  if (segname == segment_names::data) {
 // For each thread spawned, dyld will initialize its TLVs by copying the
 // address range from the start of the first thread-local data section to
 // the end of the last one. We therefore arrange these sections 
contiguously
@@ -575,7 +576,8 @@ static int sectionOrder(OutputSection *osec) {
 default:
   return 0;
 }
-  } else if (segname == segment_names::linkEdit) {
+  }
+  if (segname == segment_names::linkEdit) {
 return StringSwitch(osec->name)
 .Case(section_names::rebase, -8)
 .Case(section_names::binding, -7)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] c701f85 - [STLExtras] Use return type from operator* of the wrapped iter.

2021-01-10 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2021-01-10T14:41:13Z
New Revision: c701f85c45589091f0d232fc2bc0bc390a6ab684

URL: 
https://github.com/llvm/llvm-project/commit/c701f85c45589091f0d232fc2bc0bc390a6ab684
DIFF: 
https://github.com/llvm/llvm-project/commit/c701f85c45589091f0d232fc2bc0bc390a6ab684.diff

LOG: [STLExtras] Use return type from operator* of the wrapped iter.

Currently make_early_inc_range cannot be used with iterators with
operator* implementations that do not return a reference.

Most notably in the LLVM codebase, this means the User iterator ranges
cannot be used with make_early_inc_range, which slightly simplifies
iterating over ranges while elements are removed.

Instead of directly using BaseT::reference as return type of operator*,
this patch uses decltype to get the actual return type of the operator*
implementation in WrappedIteratorT.

This patch also updates a few places to use make use of
make_early_inc_range.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D93992

Added: 


Modified: 
llvm/include/llvm/ADT/STLExtras.h
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
llvm/unittests/ADT/STLExtrasTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/STLExtras.h 
b/llvm/include/llvm/ADT/STLExtras.h
index b534619e8193..c8c1aff9f2dd 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -538,7 +538,7 @@ class early_inc_iterator_impl
   early_inc_iterator_impl(WrappedIteratorT I) : BaseT(I) {}
 
   using BaseT::operator*;
-  typename BaseT::reference operator*() {
+  decltype(*std::declval()) operator*() {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
 assert(!IsEarlyIncremented && "Cannot dereference twice!");
 IsEarlyIncremented = true;

diff  --git a/llvm/lib/Analysis/MemoryBuiltins.cpp 
b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 5d82d9dd6ea0..21291326660a 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -378,9 +378,8 @@ PointerType *llvm::getMallocType(const CallInst *CI,
   unsigned NumOfBitCastUses = 0;
 
   // Determine if CallInst has a bitcast use.
-  for (Value::const_user_iterator UI = CI->user_begin(), E = CI->user_end();
-   UI != E;)
-if (const BitCastInst *BCI = dyn_cast(*UI++)) {
+  for (const User *U : CI->users())
+if (const BitCastInst *BCI = dyn_cast(U)) {
   MallocType = cast(BCI->getDestTy());
   NumOfBitCastUses++;
 }

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 4d17fc304d0c..e863f8e52a26 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -3894,8 +3894,8 @@ void llvm::UpgradeCallsToIntrinsic(Function *F) {
   if (UpgradeIntrinsicFunction(F, NewFn)) {
 // Replace all users of the old function with the new function or new
 // instructions. This is not a range loop because the call is deleted.
-for (auto UI = F->user_begin(), UE = F->user_end(); UI != UE; )
-  if (CallInst *CI = dyn_cast(*UI++))
+for (User *U : make_early_inc_range(F->users()))
+  if (CallInst *CI = dyn_cast(U))
 UpgradeIntrinsicCall(CI, NewFn);
 
 // Remove old function, no longer used, from the module.
@@ -4031,8 +4031,8 @@ void llvm::UpgradeARCRuntime(Module &M) {
 
 Function *NewFn = llvm::Intrinsic::getDeclaration(&M, IntrinsicFunc);
 
-for (auto I = Fn->user_begin(), E = Fn->user_end(); I != E;) {
-  CallInst *CI = dyn_cast(*I++);
+for (User *U : make_early_inc_range(Fn->users())) {
+  CallInst *CI = dyn_cast(U);
   if (!CI || CI->getCalledFunction() != Fn)
 continue;
 

diff  --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp 
b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index eaaee9a520ab..f6b8c3e44456 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -160,8 +160,8 @@ doPromotion(Function *F, SmallPtrSetImpl 
&ArgsToPromote,
   // In this table, we will track which indices are loaded from the 
argument
   // (where direct loads are tracked as no indices).
   ScalarizeTable &ArgIndices = ScalarizedElements[&*I];
-  for (auto Iter = I->user_begin(), End = I->user_end(); Iter != End;) {
-Instruction *UI = cast(*Iter++);
+  for (User *U : make_early_inc_range(I->users())) {
+Instruction *UI = cast(U);
 Type *SrcTy;
 if (LoadInst *L = dyn_cast(UI))
   SrcTy = L->getType();

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index a3d86e26fe23..0b53007b

[llvm-branch-commits] [llvm] bdb748a - [ConstantFold] Add tests for fptoi.sat (NFC)

2021-01-10 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-10T17:08:11+01:00
New Revision: bdb748a0ab24b9d87f98d3cdbecdbbf504aed930

URL: 
https://github.com/llvm/llvm-project/commit/bdb748a0ab24b9d87f98d3cdbecdbbf504aed930
DIFF: 
https://github.com/llvm/llvm-project/commit/bdb748a0ab24b9d87f98d3cdbecdbbf504aed930.diff

LOG: [ConstantFold] Add tests for fptoi.sat (NFC)

Added: 
llvm/test/Transforms/InstSimplify/fptoi-sat.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/InstSimplify/fptoi-sat.ll 
b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
new file mode 100644
index ..c418abd76019
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
@@ -0,0 +1,684 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instsimplify < %s | FileCheck %s
+
+declare i32 @llvm.fptosi.sat.i32.f64(double)
+declare i32 @llvm.fptoui.sat.i32.f64(double)
+declare i32 @llvm.fptosi.sat.i32.f32(float)
+declare i32 @llvm.fptoui.sat.i32.f32(float)
+
+declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double>)
+declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double>)
+declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float>)
+declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float>)
+
+;
+;
+; F64 -> I32
+;
+;
+
+define i32 @fptosi_f64_to_i32_poison() {
+; CHECK-LABEL: @fptosi_f64_to_i32_poison(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double poison)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double poison)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_undef() {
+; CHECK-LABEL: @fptosi_f64_to_i32_undef(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double undef)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double undef)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_pos_zero() {
+; CHECK-LABEL: @fptosi_f64_to_i32_pos_zero(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0.00e+00)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_neg_zero() {
+; CHECK-LABEL: @fptosi_f64_to_i32_neg_zero(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
-0.00e+00)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_exact() {
+; CHECK-LABEL: @fptosi_f64_to_i32_exact(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
4.20e+01)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_trunc() {
+; CHECK-LABEL: @fptosi_f64_to_i32_trunc(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
4.29e+01)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.9)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_trunc_neg() {
+; CHECK-LABEL: @fptosi_f64_to_i32_trunc_neg(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
-4.29e+01)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -42.9)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max_minus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max_minus_1(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0x41DFFF80)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483646.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0x41DFFFC0)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483647.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max_plus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max_plus_1(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0x41E0)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min_plus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min_plus_1(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0xC1DFFFC0)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -2147483647.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0xC1E0)
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min_minus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min_minus_1(
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0xC1E00020)
+; CHEC

[llvm-branch-commits] [llvm] 1ecae1e - [ConstantFold] Fold fptoi.sat intrinsics

2021-01-10 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-10T17:37:27+01:00
New Revision: 1ecae1e62ad016f0c12c204ce312fdfd653ca8cf

URL: 
https://github.com/llvm/llvm-project/commit/1ecae1e62ad016f0c12c204ce312fdfd653ca8cf
DIFF: 
https://github.com/llvm/llvm-project/commit/1ecae1e62ad016f0c12c204ce312fdfd653ca8cf.diff

LOG: [ConstantFold] Fold fptoi.sat intrinsics

The APFloat::convertToInteger() API already implements the desired
saturation semantics.

Added: 


Modified: 
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Transforms/InstSimplify/fptoi-sat.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index 22b9acbc03b8..f73890d548f0 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1515,6 +1515,8 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, 
const Function *F) {
   case Intrinsic::powi:
   case Intrinsic::fma:
   case Intrinsic::fmuladd:
+  case Intrinsic::fptoui_sat:
+  case Intrinsic::fptosi_sat:
   case Intrinsic::convert_from_fp16:
   case Intrinsic::convert_to_fp16:
   case Intrinsic::amdgcn_cos:
@@ -1850,8 +1852,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
   if (isa(Operands[0])) {
 // cosine(arg) is between -1 and 1. cosine(invalid arg) is NaN.
 // ctpop() is between 0 and bitwidth, pick 0 for undef.
+// fptoui.sat and fptosi.sat can always fold to zero (for a zero input).
 if (IntrinsicID == Intrinsic::cos ||
-IntrinsicID == Intrinsic::ctpop)
+IntrinsicID == Intrinsic::ctpop ||
+IntrinsicID == Intrinsic::fptoui_sat ||
+IntrinsicID == Intrinsic::fptosi_sat)
   return Constant::getNullValue(Ty);
 if (IntrinsicID == Intrinsic::bswap ||
 IntrinsicID == Intrinsic::bitreverse ||
@@ -1923,6 +1928,16 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
   : ConstantInt::get(Ty, APInt::getMaxValue(Width));
 }
 
+if (IntrinsicID == Intrinsic::fptoui_sat ||
+IntrinsicID == Intrinsic::fptosi_sat) {
+  // convertToInteger() already has the desired saturation semantics.
+  APSInt Int(Ty->getIntegerBitWidth(),
+ IntrinsicID == Intrinsic::fptoui_sat);
+  bool IsExact;
+  U.convertToInteger(Int, APFloat::rmTowardZero, &IsExact);
+  return ConstantInt::get(Ty, Int);
+}
+
 if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
   return nullptr;
 

diff  --git a/llvm/test/Transforms/InstSimplify/fptoi-sat.ll 
b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
index c418abd76019..dcc0505a0cd8 100644
--- a/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
+++ b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
@@ -19,8 +19,7 @@ declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float>)
 
 define i32 @fptosi_f64_to_i32_poison() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_poison(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double poison)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 0
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double poison)
   ret i32 %r
@@ -28,8 +27,7 @@ define i32 @fptosi_f64_to_i32_poison() {
 
 define i32 @fptosi_f64_to_i32_undef() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_undef(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double undef)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 0
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double undef)
   ret i32 %r
@@ -37,8 +35,7 @@ define i32 @fptosi_f64_to_i32_undef() {
 
 define i32 @fptosi_f64_to_i32_pos_zero() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_pos_zero(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
0.00e+00)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 0
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double 0.0)
   ret i32 %r
@@ -46,8 +43,7 @@ define i32 @fptosi_f64_to_i32_pos_zero() {
 
 define i32 @fptosi_f64_to_i32_neg_zero() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_neg_zero(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
-0.00e+00)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 0
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double -0.0)
   ret i32 %r
@@ -55,8 +51,7 @@ define i32 @fptosi_f64_to_i32_neg_zero() {
 
 define i32 @fptosi_f64_to_i32_exact() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_exact(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
4.20e+01)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 42
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.0)
   ret i32 %r
@@ -64,8 +59,7 @@ define i32 @fptosi_f64_to_i32_exact() {
 
 define i32 @fptosi_f64_to_i32_trunc() {
 ; CHECK-LABEL: @fptosi_f64_to_i32_trunc(
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 
4.29e+01)
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 42
 ;
   %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.9)
  

[llvm-branch-commits] [llvm] 9850d3b - [CodeGen, DebugInfo] Use llvm::find_if (NFC)

2021-01-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-10T09:24:53-08:00
New Revision: 9850d3b10a10aff00d31adf0633a4ba2b840f824

URL: 
https://github.com/llvm/llvm-project/commit/9850d3b10a10aff00d31adf0633a4ba2b840f824
DIFF: 
https://github.com/llvm/llvm-project/commit/9850d3b10a10aff00d31adf0633a4ba2b840f824.diff

LOG: [CodeGen, DebugInfo] Use llvm::find_if (NFC)

Added: 


Modified: 
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
llvm/lib/CodeGen/RegisterScavenging.cpp
llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 85371d0d5d31..564a3d7d9bc8 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -633,8 +633,8 @@ void CodeGenPrepare::removeAllAssertingVHReferences(Value 
*V) {
 return;
 
   auto &GEPVector = VecI->second;
-  const auto &I = std::find_if(GEPVector.begin(), GEPVector.end(),
-   [=](auto &Elt) { return Elt.first == GEP; });
+  const auto &I =
+  llvm::find_if(GEPVector, [=](auto &Elt) { return Elt.first == GEP; });
   if (I == GEPVector.end())
 return;
 

diff  --git a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp 
b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
index a068e6669957..ff3f93d51ea8 100644
--- a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
+++ b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
@@ -1104,10 +1104,8 @@ InterleavedLoadCombineImpl::findFirstLoad(const 
std::set &LIs) {
 
   // All LIs are within the same BB. Select the first for a reference.
   BasicBlock *BB = (*LIs.begin())->getParent();
-  BasicBlock::iterator FLI =
-  std::find_if(BB->begin(), BB->end(), [&LIs](Instruction &I) -> bool {
-return is_contained(LIs, &I);
-  });
+  BasicBlock::iterator FLI = llvm::find_if(
+  *BB, [&LIs](Instruction &I) -> bool { return is_contained(LIs, &I); });
   assert(FLI != BB->end());
 
   return cast(FLI);

diff  --git a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp 
b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
index f820b6cc3fc4..b6fb6731d65c 100644
--- a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -275,9 +275,9 @@ static bool rescheduleCanonically(unsigned 
&PseudoIdempotentInstCount,
   // Sort the defs for users of multiple defs lexographically.
   for (const auto &E : MultiUserLookup) {
 
-auto UseI =
-std::find_if(MBB->instr_begin(), MBB->instr_end(),
- [&](MachineInstr &MI) -> bool { return &MI == E.second; 
});
+auto UseI = llvm::find_if(MBB->instrs(), [&](MachineInstr &MI) -> bool {
+  return &MI == E.second;
+});
 
 if (UseI == MBB->instr_end())
   continue;

diff  --git a/llvm/lib/CodeGen/RegisterScavenging.cpp 
b/llvm/lib/CodeGen/RegisterScavenging.cpp
index ab8f4fd9778b..93e8e27d12aa 100644
--- a/llvm/lib/CodeGen/RegisterScavenging.cpp
+++ b/llvm/lib/CodeGen/RegisterScavenging.cpp
@@ -634,11 +634,10 @@ static Register scavengeVReg(MachineRegisterInfo &MRI, 
RegScavenger &RS,
   // we get a single contiguous lifetime.
   //
   // Definitions in MRI.def_begin() are unordered, search for the first.
-  MachineRegisterInfo::def_iterator FirstDef =
-std::find_if(MRI.def_begin(VReg), MRI.def_end(),
- [VReg, &TRI](const MachineOperand &MO) {
-  return !MO.getParent()->readsRegister(VReg, &TRI);
-});
+  MachineRegisterInfo::def_iterator FirstDef = llvm::find_if(
+  MRI.def_operands(VReg), [VReg, &TRI](const MachineOperand &MO) {
+return !MO.getParent()->readsRegister(VReg, &TRI);
+  });
   assert(FirstDef != MRI.def_end() &&
  "Must have one definition that does not redefine vreg");
   MachineInstr &DefMI = *FirstDef->getParent();

diff  --git a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp 
b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
index dd0b9d4c2e48..4408011c95c0 100644
--- a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
+++ b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
@@ -202,8 +202,8 @@ void SwiftErrorValueTracking::propagateVRegs() {
   // downward defs.
   bool needPHI =
   VRegs.size() >= 1 &&
-  std::find_if(
-  VRegs.begin(), VRegs.end(),
+  llvm::find_if(
+  VRegs,
   [&](const std::pair &V)
   -> bool { return V.second != VRegs[0].second; }) !=
   VRegs.end();

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
index 252b58e5a591..ace7000f07b2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
@@ -71,8 +71,8 @@ void DWARFGdbIndex::dumpSymbolTable

[llvm-branch-commits] [llvm] 1d10a1d - [MemorySSA] Remove unused dominatesUse (NFC)

2021-01-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-10T09:24:55-08:00
New Revision: 1d10a1d5b1ff8fc9ce923b6ea92f049c73a669ab

URL: 
https://github.com/llvm/llvm-project/commit/1d10a1d5b1ff8fc9ce923b6ea92f049c73a669ab
DIFF: 
https://github.com/llvm/llvm-project/commit/1d10a1d5b1ff8fc9ce923b6ea92f049c73a669ab.diff

LOG: [MemorySSA] Remove unused dominatesUse (NFC)

The function was introduced without a use on Feb 2, 2016 in commit
e1100f533f0a48f55e80e1152b06f5deab5f9b30.

Added: 


Modified: 
llvm/include/llvm/Analysis/MemorySSA.h
llvm/lib/Analysis/MemorySSA.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/MemorySSA.h 
b/llvm/include/llvm/Analysis/MemorySSA.h
index 5dfae50ad3ae..63c031b1921f 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -850,7 +850,6 @@ class MemorySSA {
   using DefsMap = DenseMap>;
 
   void markUnreachableAsLiveOnEntry(BasicBlock *BB);
-  bool dominatesUse(const MemoryAccess *, const MemoryAccess *) const;
   MemoryPhi *createMemoryPhi(BasicBlock *BB);
   template 
   MemoryUseOrDef *createNewAccess(Instruction *, AliasAnalysisType *,

diff  --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index e728a5f998f4..f0d27e0b2c6b 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -1817,23 +1817,6 @@ MemoryUseOrDef *MemorySSA::createNewAccess(Instruction 
*I,
   return MUD;
 }
 
-/// Returns true if \p Replacer dominates \p Replacee .
-bool MemorySSA::dominatesUse(const MemoryAccess *Replacer,
- const MemoryAccess *Replacee) const {
-  if (isa(Replacee))
-return DT->dominates(Replacer->getBlock(), Replacee->getBlock());
-  const auto *MP = cast(Replacee);
-  // For a phi node, the use occurs in the predecessor block of the phi node.
-  // Since we may occur multiple times in the phi node, we have to check each
-  // operand to ensure Replacer dominates each operand where Replacee occurs.
-  for (const Use &Arg : MP->operands()) {
-if (Arg.get() != Replacee &&
-!DT->dominates(Replacer->getBlock(), MP->getIncomingBlock(Arg)))
-  return false;
-  }
-  return true;
-}
-
 /// Properly remove \p MA from all of MemorySSA's lookup tables.
 void MemorySSA::removeFromLookups(MemoryAccess *MA) {
   assert(MA->use_empty() &&



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] e3d3dbd - [llvm] Ensure newlines at the end of files (NFC)

2021-01-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-10T09:24:57-08:00
New Revision: e3d3dbd33930b7bc879b522d65f6d27c1677253e

URL: 
https://github.com/llvm/llvm-project/commit/e3d3dbd33930b7bc879b522d65f6d27c1677253e
DIFF: 
https://github.com/llvm/llvm-project/commit/e3d3dbd33930b7bc879b522d65f6d27c1677253e.diff

LOG: [llvm] Ensure newlines at the end of files (NFC)

This patch eliminates pesky "No newline at end of file" messages from
git diff.

Added: 


Modified: 
llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h
llvm/include/llvm/Analysis/MLInlineAdvisor.h
llvm/include/llvm/Target/CGPassBuilderOption.h
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/LiveIntervalCalc.cpp
llvm/lib/Target/AArch64/AArch64InstrGISel.td
llvm/lib/Target/Mips/MipsInstrInfo.cpp
llvm/lib/Target/PowerPC/PPCCCState.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h 
b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index a39c4e5413d8d..a5f96e72ce978 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -83,4 +83,4 @@ class FunctionPropertiesPrinterPass
 };
 
 } // namespace llvm
-#endif // LLVM_FUNCTIONPROPERTIESANALYSIS_H_
\ No newline at end of file
+#endif // LLVM_FUNCTIONPROPERTIESANALYSIS_H_

diff  --git a/llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h 
b/llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h
index 5fc919a6dc56f..ab2cf52494c01 100644
--- a/llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h
+++ b/llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h
@@ -42,4 +42,4 @@ class InlineSizeEstimatorAnalysisPrinterPass
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
-#endif // LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H
\ No newline at end of file
+#endif // LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H

diff  --git a/llvm/include/llvm/Analysis/MLInlineAdvisor.h 
b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
index cbe3b1f1f4e6e..5dedef06f53db 100644
--- a/llvm/include/llvm/Analysis/MLInlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
@@ -104,4 +104,4 @@ class MLInlineAdvice : public InlineAdvice {
 
 } // namespace llvm
 
-#endif // LLVM_ANALYSIS_MLINLINEADVISOR_H
\ No newline at end of file
+#endif // LLVM_ANALYSIS_MLINLINEADVISOR_H

diff  --git a/llvm/include/llvm/Target/CGPassBuilderOption.h 
b/llvm/include/llvm/Target/CGPassBuilderOption.h
index 13b8e68b75a30..c3a221e01ceb7 100644
--- a/llvm/include/llvm/Target/CGPassBuilderOption.h
+++ b/llvm/include/llvm/Target/CGPassBuilderOption.h
@@ -62,4 +62,4 @@ CGPassBuilderOption getCGPassBuilderOption();
 
 } // namespace llvm
 
-#endif // LLVM_CODEGEN_PASSBUILDER_OPTION_H
\ No newline at end of file
+#endif // LLVM_CODEGEN_PASSBUILDER_OPTION_H

diff  --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp 
b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index b6ff27dcaf55a..33519038e2259 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -85,4 +85,4 @@ FunctionPropertiesPrinterPass::run(Function &F, 
FunctionAnalysisManager &AM) {
  << "\n";
   AM.getResult(F).print(OS);
   return PreservedAnalyses::all();
-}
\ No newline at end of file
+}

diff  --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 61b2611866f2c..bd0f2ec6b4ffa 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -6246,4 +6246,4 @@ LegalizerHelper::LegalizeResult 
LegalizerHelper::lowerSelect(MachineInstr &MI) {
   MIRBuilder.buildOr(DstReg, NewOp1, NewOp2);
   MI.eraseFromParent();
   return Legalized;
-}
\ No newline at end of file
+}

diff  --git a/llvm/lib/CodeGen/LiveIntervalCalc.cpp 
b/llvm/lib/CodeGen/LiveIntervalCalc.cpp
index e8fd069d17a0a..2756086cb8b1a 100644
--- a/llvm/lib/CodeGen/LiveIntervalCalc.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalCalc.cpp
@@ -202,4 +202,4 @@ void LiveIntervalCalc::extendToUses(LiveRange &LR, Register 
Reg,
 // reading Reg multiple times. That is OK, extend() is idempotent.
 extend(LR, UseIdx, Reg, Undefs);
   }
-}
\ No newline at end of file
+}

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrGISel.td 
b/llvm/lib/Target/AArch64/AArch64InstrGISel.td
index ec7817beaeb84..430155c52302e 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrGISel.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrGISel.td
@@ -167,4 +167,4 @@ def : GINodeEquiv;
 // These are patterns that we only use for GlobalISel via the importer.
 def : Pat<(f32 (fadd (vector_extract (v2f32 FPR64:$Rn), (i64 0)),
  (vector_extract (v2f32 FPR64:$Rn), (i

[llvm-branch-commits] [llvm] 0aa75fb - [SLP] put verifyFunction call behind EXPENSIVE_CHECKS

2021-01-10 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-01-10T12:32:21-05:00
New Revision: 0aa75fb12faa04e07ba1a6e334605357b6a159c9

URL: 
https://github.com/llvm/llvm-project/commit/0aa75fb12faa04e07ba1a6e334605357b6a159c9
DIFF: 
https://github.com/llvm/llvm-project/commit/0aa75fb12faa04e07ba1a6e334605357b6a159c9.diff

LOG: [SLP] put verifyFunction call behind EXPENSIVE_CHECKS

A severe compile-time slowdown from this call is noted in:
https://llvm.org/PR48689
My naive fix was to put it under LLVM_DEBUG ( 267ff79 ),
but that's not limiting in the way we want.
This is a quick fix (or we could just remove the call completely
and rely on some later pass to discover potentially wrong IR?).
A bigger/better fix would be to improve/limit verifyFunction()
as noted in:
https://llvm.org/PR47712

Differential Revision: https://reviews.llvm.org/D94328

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f124dd8ef374..d0b6b432e93e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2499,7 +2499,11 @@ BoUpSLP::~BoUpSLP() {
"trying to erase instruction with users.");
 Pair.getFirst()->eraseFromParent();
   }
-  LLVM_DEBUG(verifyFunction(*F));
+#ifdef EXPENSIVE_CHECKS
+  // If we could guarantee that this call is not extremely slow, we could
+  // remove the ifdef limitation (see PR47712).
+  assert(!verifyFunction(*F, %dbgs()));
+#endif
 }
 
 void BoUpSLP::eraseInstructions(ArrayRef AV) {



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 3f09c77 - [SLP] fix typo in assert

2021-01-10 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-01-10T13:15:04-05:00
New Revision: 3f09c77d33dcd74b3cba4558b07f88d87ab2dd9d

URL: 
https://github.com/llvm/llvm-project/commit/3f09c77d33dcd74b3cba4558b07f88d87ab2dd9d
DIFF: 
https://github.com/llvm/llvm-project/commit/3f09c77d33dcd74b3cba4558b07f88d87ab2dd9d.diff

LOG: [SLP] fix typo in assert

This snuck into 0aa75fb12faa , but I didn't catch it locally.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index d0b6b432e93e..5b91495bd844 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2502,7 +2502,7 @@ BoUpSLP::~BoUpSLP() {
 #ifdef EXPENSIVE_CHECKS
   // If we could guarantee that this call is not extremely slow, we could
   // remove the ifdef limitation (see PR47712).
-  assert(!verifyFunction(*F, %dbgs()));
+  assert(!verifyFunction(*F, &dbgs()));
 #endif
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 377dcfd - [Tests] Auto update a vectorizer test to simplify future diff

2021-01-10 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-10T12:23:22-08:00
New Revision: 377dcfd5c15d8e2c9e71a171635529052a96e244

URL: 
https://github.com/llvm/llvm-project/commit/377dcfd5c15d8e2c9e71a171635529052a96e244
DIFF: 
https://github.com/llvm/llvm-project/commit/377dcfd5c15d8e2c9e71a171635529052a96e244.diff

LOG: [Tests] Auto update a vectorizer test to simplify future diff

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll 
b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
index a3cdf7bf3e40..208e1a219be8 100644
--- a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
+++ b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S 
%s | FileCheck %s
 
 
@@ -7,32 +8,62 @@
 ; Test case for PR43398.
 
 define void @can_sink_after_store(i32 %x, i32* %ptr, i64 %tc) 
local_unnamed_addr #0 {
-; CHECK-LABEL: vector.ph:
-; CHECK:%broadcast.splatinsert = insertelement <4 x i32> poison, i32 
%x, i32 0
-; CHECK-NEXT:   %broadcast.splat = shufflevector <4 x i32> 
%broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
-; CHECK-NEXT:   %vector.recur.init = insertelement <4 x i32> poison, i32 
%.pre, i32 3
-; CHECK-NEXT:br label %vector.body
-
-; CHECK-LABEL: vector.body:
-; CHECK-NEXT:   %index = phi i64 [ 0, %vector.ph ], [ %index.next, 
%vector.body ]
-; CHECK-NEXT:   %vector.recur = phi <4 x i32> [ %vector.recur.init, %vector.ph 
], [ %wide.load, %vector.body ]
-; CHECK-NEXT:   %offset.idx = add i64 1, %index
-; CHECK-NEXT:   %0 = add i64 %offset.idx, 0
-; CHECK-NEXT:   %1 = getelementptr inbounds [257 x i32], [257 x i32]* @p, i64 
0, i64 %0
-; CHECK-NEXT:   %2 = getelementptr inbounds i32, i32* %1, i32 0
-; CHECK-NEXT:   %3 = bitcast i32* %2 to <4 x i32>*
-; CHECK-NEXT:   %wide.load = load <4 x i32>, <4 x i32>* %3, align 4
-; CHECK-NEXT:   %4 = shufflevector <4 x i32> %vector.recur, <4 x i32> 
%wide.load, <4 x i32> 
-; CHECK-NEXT:   %5 = add <4 x i32> %4, %broadcast.splat
-; CHECK-NEXT:   %6 = add <4 x i32> %5, %wide.load
-; CHECK-NEXT:   %7 = getelementptr inbounds [257 x i32], [257 x i32]* @q, i64 
0, i64 %0
-; CHECK-NEXT:   %8 = getelementptr inbounds i32, i32* %7, i32 0
-; CHECK-NEXT:   %9 = bitcast i32* %8 to <4 x i32>*
-; CHECK-NEXT:   store <4 x i32> %6, <4 x i32>* %9, align 4
-; CHECK-NEXT:   %index.next = add i64 %index, 4
-; CHECK-NEXT:   %10 = icmp eq i64 %index.next, 1996
-; CHECK-NEXT:   br i1 %10, label %middle.block, label %vector.body
+; CHECK-LABEL: @can_sink_after_store(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[PREHEADER:%.*]]
+; CHECK:   preheader:
+; CHECK-NEXT:[[IDX_PHI_TRANS:%.*]] = getelementptr inbounds [257 x i32], 
[257 x i32]* @p, i64 0, i64 1
+; CHECK-NEXT:[[DOTPRE:%.*]] = load i32, i32* [[IDX_PHI_TRANS]], align 4
+; CHECK-NEXT:br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:[[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> 
poison, i32 [[X:%.*]], i32 0
+; CHECK-NEXT:[[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> 
[[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:[[VECTOR_RECUR_INIT:%.*]] = insertelement <4 x i32> poison, 
i32 [[DOTPRE]], i32 3
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[VECTOR_RECUR:%.*]] = phi <4 x i32> [ [[VECTOR_RECUR_INIT]], 
[[VECTOR_PH]] ], [ [[WIDE_LOAD:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[OFFSET_IDX:%.*]] = add i64 1, [[INDEX]]
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[OFFSET_IDX]], 0
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds [257 x i32], [257 x 
i32]* @p, i64 0, i64 [[TMP0]]
+; CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i32, i32* [[TMP1]], i32 0
+; CHECK-NEXT:[[TMP3:%.*]] = bitcast i32* [[TMP2]] to <4 x i32>*
+; CHECK-NEXT:[[WIDE_LOAD]] = load <4 x i32>, <4 x i32>* [[TMP3]], align 4
+; CHECK-NEXT:[[TMP4:%.*]] = shufflevector <4 x i32> [[VECTOR_RECUR]], <4 x 
i32> [[WIDE_LOAD]], <4 x i32> 
+; CHECK-NEXT:[[TMP5:%.*]] = add <4 x i32> [[TMP4]], [[BROADCAST_SPLAT]]
+; CHECK-NEXT:[[TMP6:%.*]] = add <4 x i32> [[TMP5]], [[WIDE_LOAD]]
+; CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds [257 x i32], [257 x 
i32]* @q, i64 0, i64 [[TMP0]]
+; CHECK-NEXT:[[TMP8:%.*]] = getelementptr inbounds i32, i32* [[TMP7]], i32 0
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32* [[TMP8]] to <4 x i32>*
+; CHECK-NEXT:store <4 x i32> [[TMP6]], <4 x i32>* [[TMP9]], align 4
+; CHECK-NEX

[llvm-branch-commits] [clang] abfe348 - [test] Improve CodeGenCXX/difile_entry.cpp

2021-01-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-10T12:24:49-08:00
New Revision: abfe348e6b4c50c750d70adcf0b99fd3d8d4132e

URL: 
https://github.com/llvm/llvm-project/commit/abfe348e6b4c50c750d70adcf0b99fd3d8d4132e
DIFF: 
https://github.com/llvm/llvm-project/commit/abfe348e6b4c50c750d70adcf0b99fd3d8d4132e.diff

LOG: [test] Improve CodeGenCXX/difile_entry.cpp

The test added in D87147 did not actually test PR47391.
Use an absolute path to test the canonicalization.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/difile_entry.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8bc28b28c048..5bdda26a2e8e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -409,6 +409,9 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation 
Loc) {
   FileID FID;
 
   if (Loc.isInvalid()) {
+// The DIFile used by the CU is distinct from the main source file. Call
+// createFile() below for canonicalization if the source file was specified
+// with an absolute path.
 FileName = TheCU->getFile()->getFilename();
   } else {
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);

diff  --git a/clang/test/CodeGenCXX/difile_entry.cpp 
b/clang/test/CodeGenCXX/difile_entry.cpp
index 1ae36e4355ce..8bf6dc325470 100644
--- a/clang/test/CodeGenCXX/difile_entry.cpp
+++ b/clang/test/CodeGenCXX/difile_entry.cpp
@@ -1,12 +1,13 @@
-// RUN: rm -rf %t/test_dir
-// RUN: mkdir -p %t/test_dir
-// RUN: cd %t/test_dir
+/// PR47391: if the filename is absolute and starts with current working
+/// directory, there may be two ways describing the filename field of DIFile.
+/// Test that we canonicalize the DIFile.
+// RUN: rm -rf %t && mkdir %t && cd %t
 // RUN: cp %s .
-// RUN: %clang_cc1 -triple %itanium_abi_triple -main-file-name 
difile_entry.cpp -debug-info-kind=limited ../test_dir/difile_entry.cpp 
-std=c++11 -emit-llvm -o - | FileCheck  ../test_dir/difile_entry.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -main-file-name 
difile_entry.cpp -debug-info-kind=limited %t/difile_entry.cpp -std=c++11 
-emit-llvm -o - | FileCheck %s
 int x();
 static int i = x();
 
-// CHECK: [[FILE: *]] = !DIFile(filename: "{{.*}}difile_entry.cpp",
-// CHECK: {{.*}} = distinct !DISubprogram(name: "__cxx_global_var_init", 
scope: {{.*}}, file: [[FILE]]
-// CHECK: {{.*}} = distinct !DISubprogram(linkageName: 
"_GLOBAL__sub_I_difile_entry.cpp", scope: {{.*}}, file: [[FILE]]
-
+// CHECK: distinct !DIGlobalVariable(name: "i", {{.*}}, file: ![[#FILE:]],
+// CHECK: ![[#FILE]] = !DIFile(filename: "difile_entry.cpp", directory:
+// CHECK: distinct !DISubprogram(name: "__cxx_global_var_init", {{.*}}, file: 
![[#FILE]],
+// CHECK: distinct !DISubprogram(linkageName: 
"_GLOBAL__sub_I_difile_entry.cpp", {{.*}}, file: ![[#FILE]]



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 86d6f7e - Precommit tests requested for D93725

2021-01-10 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-10T12:29:34-08:00
New Revision: 86d6f7e90a1deab93e357b8f356e29d4a24fa3ac

URL: 
https://github.com/llvm/llvm-project/commit/86d6f7e90a1deab93e357b8f356e29d4a24fa3ac
DIFF: 
https://github.com/llvm/llvm-project/commit/86d6f7e90a1deab93e357b8f356e29d4a24fa3ac.diff

LOG: Precommit tests requested for D93725

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
llvm/test/Transforms/LoopVectorize/loop-form.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll 
b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
index 208e1a219be8..ef3d3e659e5a 100644
--- a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
+++ b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
@@ -432,3 +432,94 @@ loop.latch:; preds 
= %if.then122, %for.b
 exit:
   ret void
 }
+
+; A recurrence in a multiple exit loop.
+define i16 @multiple_exit(i16* %p, i32 %n) {
+; CHECK-LABEL: @multiple_exit(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_COND:%.*]]
+; CHECK:   for.cond:
+; CHECK-NEXT:[[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY:%.*]] ]
+; CHECK-NEXT:[[REC:%.*]] = phi i16 [ 0, [[ENTRY]] ], [ [[REC_NEXT:%.*]], 
[[FOR_BODY]] ]
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], i64 
[[IPROM]]
+; CHECK-NEXT:[[REC_NEXT]] = load i16, i16* [[B]], align 2
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[I]], [[N:%.*]]
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY]], label [[IF_END:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:store i16 [[REC]], i16* [[B]], align 4
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I]], 1
+; CHECK-NEXT:[[CMP2:%.*]] = icmp slt i32 [[I]], 2096
+; CHECK-NEXT:br i1 [[CMP2]], label [[FOR_COND]], label [[IF_END]]
+; CHECK:   if.end:
+; CHECK-NEXT:[[REC_LCSSA:%.*]] = phi i16 [ [[REC]], [[FOR_BODY]] ], [ 
[[REC]], [[FOR_COND]] ]
+; CHECK-NEXT:ret i16 [[REC_LCSSA]]
+;
+entry:
+  br label %for.cond
+
+for.cond:
+  %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %rec = phi i16 [0, %entry], [ %rec.next, %for.body ]
+  %iprom = sext i32 %i to i64
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
+  %rec.next = load i16, i16* %b
+  %cmp = icmp slt i32 %i, %n
+  br i1 %cmp, label %for.body, label %if.end
+
+for.body:
+  store i16 %rec , i16* %b, align 4
+  %inc = add nsw i32 %i, 1
+  %cmp2 = icmp slt i32 %i, 2096
+  br i1 %cmp2, label %for.cond, label %if.end
+
+if.end:
+  ret i16 %rec
+}
+
+
+; A multiple exit case where one of the exiting edges involves a value
+; from the recurrence and one does not.
+define i16 @multiple_exit2(i16* %p, i32 %n) {
+; CHECK-LABEL: @multiple_exit2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_COND:%.*]]
+; CHECK:   for.cond:
+; CHECK-NEXT:[[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY:%.*]] ]
+; CHECK-NEXT:[[REC:%.*]] = phi i16 [ 0, [[ENTRY]] ], [ [[REC_NEXT:%.*]], 
[[FOR_BODY]] ]
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], i64 
[[IPROM]]
+; CHECK-NEXT:[[REC_NEXT]] = load i16, i16* [[B]], align 2
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[I]], [[N:%.*]]
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY]], label [[IF_END:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:store i16 [[REC]], i16* [[B]], align 4
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I]], 1
+; CHECK-NEXT:[[CMP2:%.*]] = icmp slt i32 [[I]], 2096
+; CHECK-NEXT:br i1 [[CMP2]], label [[FOR_COND]], label [[IF_END]]
+; CHECK:   if.end:
+; CHECK-NEXT:[[REC_LCSSA:%.*]] = phi i16 [ [[REC]], [[FOR_COND]] ], [ 10, 
[[FOR_BODY]] ]
+; CHECK-NEXT:ret i16 [[REC_LCSSA]]
+;
+entry:
+  br label %for.cond
+
+for.cond:
+  %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %rec = phi i16 [0, %entry], [ %rec.next, %for.body ]
+  %iprom = sext i32 %i to i64
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
+  %rec.next = load i16, i16* %b
+  %cmp = icmp slt i32 %i, %n
+  br i1 %cmp, label %for.body, label %if.end
+
+for.body:
+  store i16 %rec , i16* %b, align 4
+  %inc = add nsw i32 %i, 1
+  %cmp2 = icmp slt i32 %i, 2096
+  br i1 %cmp2, label %for.cond, label %if.end
+
+if.end:
+  %rec.lcssa = phi i16 [ %rec, %for.cond ], [ 10, %for.body ]
+  ret i16 %rec.lcssa
+}

diff  --git a/llvm/test/Transforms/LoopVectorize/loop-form.ll 
b/llvm/test/Transforms/LoopVectorize/loop-form.ll
index f93c038de6bb..bf94505aec2c 100644
--- a/llvm/test/Transforms/LoopVectorize/loop-form.ll
+++ b/llvm/test/Transforms/LoopVectorize/loop-form.ll
@@ -869,3 +869,126 @@ loop.latch:
 exit:
   ret void
 }
+
+define i32 @reduction(i32* %addr) {
+; CHECK-LABEL: @redu

[llvm-branch-commits] [llvm] fc8ab25 - [Tests] Precommit tests from to simplify rebase

2021-01-10 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-10T12:42:08-08:00
New Revision: fc8ab254472972816956c69d16e8b35bc91cc2ab

URL: 
https://github.com/llvm/llvm-project/commit/fc8ab254472972816956c69d16e8b35bc91cc2ab
DIFF: 
https://github.com/llvm/llvm-project/commit/fc8ab254472972816956c69d16e8b35bc91cc2ab.diff

LOG: [Tests] Precommit tests from to simplify rebase

Added: 
llvm/test/Transforms/LoopDeletion/zero-btc.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/LoopDeletion/zero-btc.ll 
b/llvm/test/Transforms/LoopDeletion/zero-btc.ll
new file mode 100644
index ..b56e30e8f1be
--- /dev/null
+++ b/llvm/test/Transforms/LoopDeletion/zero-btc.ll
@@ -0,0 +1,319 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-deletion -S | FileCheck %s
+
+@G = external global i32
+
+define void @test_trivial() {
+; CHECK-LABEL: @test_trivial(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:store i32 0, i32* @G, align 4
+; CHECK-NEXT:br i1 false, label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  store i32 0, i32* @G
+  br i1 false, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+
+define void @test_bottom_tested() {
+; CHECK-LABEL: @test_bottom_tested(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], 
[[LOOP]] ]
+; CHECK-NEXT:store i32 0, i32* @G, align 4
+; CHECK-NEXT:[[IV_INC]] = add i32 [[IV]], 1
+; CHECK-NEXT:[[BE_TAKEN:%.*]] = icmp ne i32 [[IV_INC]], 1
+; CHECK-NEXT:br i1 [[BE_TAKEN]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry], [ %iv.inc, %loop ]
+  store i32 0, i32* @G
+  %iv.inc = add i32 %iv, 1
+  %be_taken = icmp ne i32 %iv.inc, 1
+  br i1 %be_taken, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+define void @test_early_exit() {
+; CHECK-LABEL: @test_early_exit(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], 
[[LATCH:%.*]] ]
+; CHECK-NEXT:store i32 0, i32* @G, align 4
+; CHECK-NEXT:[[IV_INC]] = add i32 [[IV]], 1
+; CHECK-NEXT:[[BE_TAKEN:%.*]] = icmp ne i32 [[IV_INC]], 1
+; CHECK-NEXT:br i1 [[BE_TAKEN]], label [[LATCH]], label [[EXIT:%.*]]
+; CHECK:   latch:
+; CHECK-NEXT:br label [[LOOP]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry], [ %iv.inc, %latch ]
+  store i32 0, i32* @G
+  %iv.inc = add i32 %iv, 1
+  %be_taken = icmp ne i32 %iv.inc, 1
+  br i1 %be_taken, label %latch, label %exit
+latch:
+  br label %loop
+
+exit:
+  ret void
+}
+
+define void @test_multi_exit1() {
+; CHECK-LABEL: @test_multi_exit1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], 
[[LATCH:%.*]] ]
+; CHECK-NEXT:store i32 0, i32* @G, align 4
+; CHECK-NEXT:[[IV_INC]] = add i32 [[IV]], 1
+; CHECK-NEXT:[[BE_TAKEN:%.*]] = icmp ne i32 [[IV_INC]], 1
+; CHECK-NEXT:br i1 [[BE_TAKEN]], label [[LATCH]], label [[EXIT:%.*]]
+; CHECK:   latch:
+; CHECK-NEXT:store i32 1, i32* @G, align 4
+; CHECK-NEXT:[[COND2:%.*]] = icmp ult i32 [[IV_INC]], 30
+; CHECK-NEXT:br i1 [[COND2]], label [[LOOP]], label [[EXIT]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry], [ %iv.inc, %latch ]
+  store i32 0, i32* @G
+  %iv.inc = add i32 %iv, 1
+  %be_taken = icmp ne i32 %iv.inc, 1
+  br i1 %be_taken, label %latch, label %exit
+latch:
+  store i32 1, i32* @G
+  %cond2 = icmp ult i32 %iv.inc, 30
+  br i1 %cond2, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+define void @test_multi_exit2() {
+; CHECK-LABEL: @test_multi_exit2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:store i32 0, i32* @G, align 4
+; CHECK-NEXT:br i1 true, label [[LATCH:%.*]], label [[EXIT:%.*]]
+; CHECK:   latch:
+; CHECK-NEXT:store i32 1, i32* @G, align 4
+; CHECK-NEXT:br i1 false, label [[LOOP]], label [[EXIT]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  store i32 0, i32* @G
+  br i1 true, label %latch, label %exit
+latch:
+  store i32 1, i32* @G
+  br i1 false, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+; TODO: SCEV seems not to recognize this as a zero btc loop
+define void @test_multi_exit3(i1 %cond1) {
+; CHECK-LABEL: @test_multi_exit3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+;

[llvm-branch-commits] [lldb] 13dea03 - [lldb] Fix some bugs in the Pipe class and add tests

2021-01-10 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2021-01-10T21:59:16+01:00
New Revision: 13dea030b3d794d05a08dd0080c35844c9ca1b30

URL: 
https://github.com/llvm/llvm-project/commit/13dea030b3d794d05a08dd0080c35844c9ca1b30
DIFF: 
https://github.com/llvm/llvm-project/commit/13dea030b3d794d05a08dd0080c35844c9ca1b30.diff

LOG: [lldb] Fix some bugs in the Pipe class and add tests

- s/createUniqueFile/createUniquePath -- we don't want to create the file,
  just the file name
- s/data()/str().c_str()/ -- paths given to system apis must be
  null-terminated

Added: 
lldb/unittests/Host/PipeTest.cpp

Modified: 
lldb/source/Host/posix/PipePosix.cpp
lldb/unittests/Host/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index 780222dffbf8..7cd05a1ad2eb 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -117,7 +117,7 @@ Status PipePosix::CreateNew(llvm::StringRef name, bool 
child_process_inherit) {
 return Status("Pipe is already opened");
 
   Status error;
-  if (::mkfifo(name.data(), 0660) != 0)
+  if (::mkfifo(name.str().c_str(), 0660) != 0)
 error.SetErrorToErrno();
 
   return error;
@@ -138,8 +138,8 @@ Status PipePosix::CreateWithUniqueName(llvm::StringRef 
prefix,
   // try again.
   Status error;
   do {
-llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(),
-named_pipe_path);
+llvm::sys::fs::createUniquePath(tmpdir_file_spec.GetPath(), 
named_pipe_path,
+/*MakeAbsolute=*/false);
 error = CreateNew(named_pipe_path, child_process_inherit);
   } while (error.GetError() == EEXIST);
 
@@ -158,7 +158,7 @@ Status PipePosix::OpenAsReader(llvm::StringRef name,
 flags |= O_CLOEXEC;
 
   Status error;
-  int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.data(), flags);
+  int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.str().c_str(), flags);
   if (fd != -1)
 m_fds[READ] = fd;
   else
@@ -189,7 +189,7 @@ PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
 }
 
 errno = 0;
-int fd = ::open(name.data(), flags);
+int fd = ::open(name.str().c_str(), flags);
 if (fd == -1) {
   const auto errno_copy = errno;
   // We may get ENXIO if a reader side of the pipe hasn't opened yet.

diff  --git a/lldb/unittests/Host/CMakeLists.txt 
b/lldb/unittests/Host/CMakeLists.txt
index 663645c986f0..1cc0cb081e49 100644
--- a/lldb/unittests/Host/CMakeLists.txt
+++ b/lldb/unittests/Host/CMakeLists.txt
@@ -7,6 +7,7 @@ set (FILES
   HostTest.cpp
   MainLoopTest.cpp
   NativeProcessProtocolTest.cpp
+  PipeTest.cpp
   ProcessLaunchInfoTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp

diff  --git a/lldb/unittests/Host/PipeTest.cpp 
b/lldb/unittests/Host/PipeTest.cpp
new file mode 100644
index ..e8d2c49c4490
--- /dev/null
+++ b/lldb/unittests/Host/PipeTest.cpp
@@ -0,0 +1,48 @@
+//===-- PipeTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Pipe.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+class PipeTest : public testing::Test {
+public:
+  SubsystemRAII subsystems;
+};
+
+TEST_F(PipeTest, CreateWithUniqueName) {
+  Pipe pipe;
+  llvm::SmallString<0> name;
+  ASSERT_THAT_ERROR(pipe.CreateWithUniqueName("PipeTest-CreateWithUniqueName",
+  /*child_process_inherit=*/false,
+  name)
+.ToError(),
+llvm::Succeeded());
+}
+
+TEST_F(PipeTest, OpenAsReader) {
+  Pipe pipe;
+  llvm::SmallString<0> name;
+  ASSERT_THAT_ERROR(pipe.CreateWithUniqueName("PipeTest-OpenAsReader",
+  /*child_process_inherit=*/false,
+  name)
+.ToError(),
+llvm::Succeeded());
+
+  // Ensure name is not null-terminated
+  size_t name_len = name.size();
+  name += "foobar";
+  llvm::StringRef name_ref(name.data(), name_len);
+  ASSERT_THAT_ERROR(
+  pipe.OpenAsReader(name_ref, /*child_process_inherit=*/false).ToError(),
+  llvm::Succeeded());
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8e8d214 - [NFCI][SimplifyCFG] Prefer to add Insert edges before Delete edges into DomTreeUpdater, if reasonable

2021-01-10 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-11T00:30:44+03:00
New Revision: 8e8d214c4a6c417e42996faeb9211a5c2e32111f

URL: 
https://github.com/llvm/llvm-project/commit/8e8d214c4a6c417e42996faeb9211a5c2e32111f
DIFF: 
https://github.com/llvm/llvm-project/commit/8e8d214c4a6c417e42996faeb9211a5c2e32111f.diff

LOG: [NFCI][SimplifyCFG] Prefer to add Insert edges before Delete edges into 
DomTreeUpdater, if reasonable

This has a measurable impact on the number of DomTree recalculations.
While this doesn't handle all the cases,
it deals with the most obvious ones.

Added: 


Modified: 
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp 
b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index c0edde8648f5..44b9ddd3e1ee 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -141,11 +141,11 @@ static bool mergeEmptyReturnBlocks(Function &F, 
DomTreeUpdater *DTU) {
   // All predecessors of BB should now branch to RetBlock instead.
   if (DTU) {
 for (auto *Predecessor : predecessors(&BB)) {
-  Updates.push_back({DominatorTree::Delete, Predecessor, &BB});
   // But, iff Predecessor already branches to RetBlock,
   // don't (re-)add DomTree edge, because it already exists.
   if (!is_contained(successors(Predecessor), RetBlock))
 Updates.push_back({DominatorTree::Insert, Predecessor, RetBlock});
+  Updates.push_back({DominatorTree::Delete, Predecessor, &BB});
 }
   }
   BB.replaceAllUsesWith(RetBlock);

diff  --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp 
b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 0b3a25902c69..bfad88f64c7d 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -1395,11 +1395,11 @@ BasicBlock *llvm::CreateControlFlowHub(
   SmallVector Updates;
   if (DTU) {
 for (auto In : Incoming) {
+  Updates.push_back({DominatorTree::Insert, In, FirstGuardBlock});
   for (auto Succ : successors(In)) {
 if (Outgoing.count(Succ))
   Updates.push_back({DominatorTree::Delete, In, Succ});
   }
-  Updates.push_back({DominatorTree::Insert, In, FirstGuardBlock});
 }
   }
 

diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 76bc8369fe5b..52e71ad164a5 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -735,13 +735,13 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB,
   SmallVector Updates;
 
   if (DTU) {
-Updates.push_back({DominatorTree::Delete, PredBB, DestBB});
 for (auto I = pred_begin(PredBB), E = pred_end(PredBB); I != E; ++I) {
-  Updates.push_back({DominatorTree::Delete, *I, PredBB});
   // This predecessor of PredBB may already have DestBB as a successor.
   if (!llvm::is_contained(successors(*I), DestBB))
 Updates.push_back({DominatorTree::Insert, *I, DestBB});
+  Updates.push_back({DominatorTree::Delete, *I, PredBB});
 }
+Updates.push_back({DominatorTree::Delete, PredBB, DestBB});
   }
 
   // Zap anything that took the address of DestBB.  Not doing this will give 
the
@@ -1046,16 +1046,16 @@ bool 
llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
 
   SmallVector Updates;
   if (DTU) {
-Updates.push_back({DominatorTree::Delete, BB, Succ});
 // All predecessors of BB will be moved to Succ.
 SmallSetVector Predecessors(pred_begin(BB), pred_end(BB));
 Updates.reserve(Updates.size() + 2 * Predecessors.size());
 for (auto *Predecessor : Predecessors) {
-  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
   // This predecessor of BB may already have Succ as a successor.
   if (!llvm::is_contained(successors(Predecessor), Succ))
 Updates.push_back({DominatorTree::Insert, Predecessor, Succ});
+  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
 }
+Updates.push_back({DominatorTree::Delete, BB, Succ});
   }
 
   if (isa(Succ->begin())) {

diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 4bcbffda6a61..62cab573a819 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2495,8 +2495,8 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, 
DomTreeUpdater *DTU,
 PredBBTI->setSuccessor(i, EdgeBB);
   }
 
-Updates.push_back({DominatorTree::Delete, PredBB, BB});
 Updates.push_back({DominatorTree::Insert, PredBB, EdgeBB});
+Updates.push_back({DominatorTree::Delete, PredBB, BB});
 
 if (DTU)
   DTU->applyUpdates(Updates);
@@ 

[llvm-branch-commits] [llvm] 894d2db - [LLVM] Added OpenMP to `LLVM_ALL_RUNTIMES`

2021-01-10 Thread Shilei Tian via llvm-branch-commits

Author: Shilei Tian
Date: 2021-01-10T16:45:51-05:00
New Revision: 894d2dbf502026a2b063340f8214b8ffd7cf7e21

URL: 
https://github.com/llvm/llvm-project/commit/894d2dbf502026a2b063340f8214b8ffd7cf7e21
DIFF: 
https://github.com/llvm/llvm-project/commit/894d2dbf502026a2b063340f8214b8ffd7cf7e21.diff

LOG: [LLVM] Added OpenMP to `LLVM_ALL_RUNTIMES`

This patch added `openmp` to `LLVM_ALL_RUNTIMES` so that when the CMake 
argument `LLVM_ENABLE_RUNTIMES=all`, OpenMP can also be built.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94369

Added: 


Modified: 
llvm/runtimes/CMakeLists.txt

Removed: 




diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 57db5c37847d..2a03fbfbcded 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -20,7 +20,7 @@ foreach(entry ${entries})
 endforeach()
 
 # Side-by-side subprojects layout.
-set(LLVM_ALL_RUNTIMES "libcxx;libcxxabi;libunwind;compiler-rt")
+set(LLVM_ALL_RUNTIMES "libcxx;libcxxabi;libunwind;compiler-rt;openmp")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES}), or 
\"all\".")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] 7be3285 - [OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along with LLVM

2021-01-10 Thread Shilei Tian via llvm-branch-commits

Author: Shilei Tian
Date: 2021-01-10T16:46:19-05:00
New Revision: 7be3285248bf54d0784a76174cf44cf7c1e780a5

URL: 
https://github.com/llvm/llvm-project/commit/7be3285248bf54d0784a76174cf44cf7c1e780a5
DIFF: 
https://github.com/llvm/llvm-project/commit/7be3285248bf54d0784a76174cf44cf7c1e780a5.diff

LOG: [OpenMP] Not set OPENMP_STANDALONE_BUILD=ON when building OpenMP along 
with LLVM

For now, `*_STANDALONE_BUILD` is set to ON even if they're built along
with LLVM because of issues mentioned in the comments. This can cause some 
issues.
For example, if we build OpenMP along with LLVM, we'd like to copy those OpenMP
headers to `/lib/clang//include` such that `clang` can find
those headers without using `-I /include` because those headers will be
copied to `/include` if it is built standalone.

In this patch, we fixed the dependence issue in OpenMP such that it can be built
correctly even with `OPENMP_STANDALONE_BUILD=OFF`. The issue is in the call to
`add_lit_testsuite`, where `clang` and `clang-resource-headers` are passed as
`DEPENDS`. Since we're building OpenMP along with LLVM, `clang` is set by CMake
to be the C/C++ compiler, therefore these two dependences are no longer needed,
where caused the dependence issue.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D93738

Added: 


Modified: 
llvm/runtimes/CMakeLists.txt
openmp/cmake/OpenMPTesting.cmake

Removed: 




diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 2a03fbfbcded..d2f5d6bf80f0 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -60,6 +60,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
   project(Runtimes C CXX ASM)
 
   find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH 
NO_CMAKE_FIND_ROOT_PATH)
+  find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH 
NO_CMAKE_FIND_ROOT_PATH)
 
   # Add the root project's CMake modules, and the LLVM build's modules to the
   # CMake module path.
@@ -136,8 +137,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL 
${CMAKE_CURRENT_SOURCE_DIR})
 # The subdirectories need to treat this as standalone builds. D57992 tried
 # to get rid of this, but the runtimes treat *_STANDALONE_BUILD=OFF as if
 # llvm & clang are configured in the same CMake, and setup dependencies
-# against their targets.
-set(${canon_name}_STANDALONE_BUILD ON)
+# against their targets. OpenMP has fixed the issue so we don't set the
+# variable.
+if (NOT ${canon_name} STREQUAL "OPENMP")
+  set(${canon_name}_STANDALONE_BUILD ON)
+endif()
 
 if(LLVM_RUNTIMES_LIBDIR_SUBDIR)
   set(${canon_name}_LIBDIR_SUBDIR "${LLVM_RUNTIMES_LIBDIR_SUBDIR}" CACHE 
STRING "" FORCE)

diff  --git a/openmp/cmake/OpenMPTesting.cmake 
b/openmp/cmake/OpenMPTesting.cmake
index 1d46b141ffdf..7290bc48969f 100644
--- a/openmp/cmake/OpenMPTesting.cmake
+++ b/openmp/cmake/OpenMPTesting.cmake
@@ -190,14 +190,14 @@ function(add_openmp_testsuite target comment)
 ${comment}
 ${ARG_UNPARSED_ARGUMENTS}
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
+DEPENDS clang FileCheck ${ARG_DEPENDS}
 ARGS ${ARG_ARGS}
   )
 else()
   add_lit_testsuite(${target}
 ${comment}
 ${ARG_UNPARSED_ARGUMENTS}
-DEPENDS clang clang-resource-headers FileCheck ${ARG_DEPENDS}
+DEPENDS clang FileCheck ${ARG_DEPENDS}
 ARGS ${ARG_ARGS}
   )
 endif()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 407b1e6 - [StringExtras] Add a helper class for comma-separated lists

2021-01-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-10T14:32:02-08:00
New Revision: 407b1e65a464081e28c325273b65e8eafdfad1d4

URL: 
https://github.com/llvm/llvm-project/commit/407b1e65a464081e28c325273b65e8eafdfad1d4
DIFF: 
https://github.com/llvm/llvm-project/commit/407b1e65a464081e28c325273b65e8eafdfad1d4.diff

LOG: [StringExtras] Add a helper class for comma-separated lists

This patch introduces a helper class SubsequentDelim to simplify loops
that generate a comma-separated lists.

For example, consider the following loop, taken from
llvm/lib/CodeGen/MachineBasicBlock.cpp:

for (auto I = pred_begin(), E = pred_end(); I != E; ++I) {
  if (I != pred_begin())
OS << ", ";
  OS << printMBBReference(**I);
}

The new class allows us to rewrite the loop as:

SubsequentDelim SD;
for (auto I = pred_begin(), E = pred_end(); I != E; ++I)
  OS << SD << printMBBReference(**I);

where SD evaluates to the empty string for the first time and ", " for
subsequent iterations.

Unlike interleaveComma, defined in llvm/include/llvm/ADT/STLExtras.h,
SubsequentDelim can accommodate a wider variety of loops, including:

- those that conditionally skip certain items,
- those that need iterators to call getSuccProbability(I), and
- those that iterate over integer ranges.

As an example, this patch cleans up MachineBasicBlock::print.

Differential Revision: https://reviews.llvm.org/D94377

Added: 


Modified: 
llvm/include/llvm/ADT/StringExtras.h
llvm/lib/CodeGen/MachineBasicBlock.cpp
llvm/unittests/ADT/StringExtrasTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/StringExtras.h 
b/llvm/include/llvm/ADT/StringExtras.h
index 77288f8514dc..1fea700efe0c 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -462,6 +462,30 @@ inline std::string join_items(Sep Separator, Args &&... 
Items) {
   return Result;
 }
 
+/// A helper class to return the specified delimiter string after the first
+/// invocation of operator StringRef().  Used to generate a comma-separated
+/// list from a loop like so:
+///
+/// \code
+///   SubsequentDelim SD;
+///   for (auto &I : C)
+/// OS << SD << I.getName();
+/// \end
+class SubsequentDelim {
+  bool First = true;
+  StringRef Delim;
+
+ public:
+  SubsequentDelim(StringRef Delim = ", ") : Delim(Delim) {}
+  operator StringRef() {
+if (First) {
+  First = false;
+  return {};
+}
+return Delim;
+  }
+};
+
 } // end namespace llvm
 
 #endif // LLVM_ADT_STRINGEXTRAS_H

diff  --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp 
b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 14a270f994b4..c7b404e075e1 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -353,11 +353,9 @@ void MachineBasicBlock::print(raw_ostream &OS, 
ModuleSlotTracker &MST,
 if (Indexes) OS << '\t';
 // Don't indent(2), align with previous line attributes.
 OS << "; predecessors: ";
-for (auto I = pred_begin(), E = pred_end(); I != E; ++I) {
-  if (I != pred_begin())
-OS << ", ";
-  OS << printMBBReference(**I);
-}
+SubsequentDelim SD;
+for (auto *Pred : predecessors())
+  OS << SD << printMBBReference(*Pred);
 OS << '\n';
 HasLineAttributes = true;
   }
@@ -366,10 +364,9 @@ void MachineBasicBlock::print(raw_ostream &OS, 
ModuleSlotTracker &MST,
 if (Indexes) OS << '\t';
 // Print the successors
 OS.indent(2) << "successors: ";
+SubsequentDelim SD;
 for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
-  if (I != succ_begin())
-OS << ", ";
-  OS << printMBBReference(**I);
+  OS << SD << printMBBReference(**I);
   if (!Probs.empty())
 OS << '('
<< format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
@@ -378,11 +375,10 @@ void MachineBasicBlock::print(raw_ostream &OS, 
ModuleSlotTracker &MST,
 if (!Probs.empty() && IsStandalone) {
   // Print human readable probabilities as comments.
   OS << "; ";
+  SubsequentDelim SD;
   for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
 const BranchProbability &BP = getSuccProbability(I);
-if (I != succ_begin())
-  OS << ", ";
-OS << printMBBReference(**I) << '('
+OS << SD << printMBBReference(**I) << '('
<< format("%.2f%%",
  rint(((double)BP.getNumerator() / BP.getDenominator()) *
   100.0 * 100.0) /
@@ -399,12 +395,9 @@ void MachineBasicBlock::print(raw_ostream &OS, 
ModuleSlotTracker &MST,
 if (Indexes) OS << '\t';
 OS.indent(2) << "liveins: ";
 
-bool First = true;
+SubsequentDelim SD;
 for (const auto &LI : liveins()) {
-  if (!First)
-OS << ", ";
-  First = false;
-  OS << printReg(LI.PhysReg, TRI);
+  OS << SD << printReg(LI.PhysReg, TRI);
   if (!LI.LaneMask.all

[llvm-branch-commits] [clang] 02bc320 - CGDebugInfo: Delete unused DIFile* parameter

2021-01-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-10T15:03:40-08:00
New Revision: 02bc320545deb0212a43acae24fcf2383755d383

URL: 
https://github.com/llvm/llvm-project/commit/02bc320545deb0212a43acae24fcf2383755d383
DIFF: 
https://github.com/llvm/llvm-project/commit/02bc320545deb0212a43acae24fcf2383755d383.diff

LOG: CGDebugInfo: Delete unused DIFile* parameter

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5bdda26a2e8e..74ec683fe6e5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2404,7 +2404,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
RecordType *Ty) {
   // its members.  Finally, we create a descriptor for the complete type (which
   // may refer to the forward decl if the struct is recursive) and replace all
   // uses of the forward declaration with the final definition.
-  llvm::DICompositeType *FwdDecl = getOrCreateLimitedType(Ty, DefUnit);
+  llvm::DICompositeType *FwdDecl = getOrCreateLimitedType(Ty);
 
   const RecordDecl *D = RD->getDefinition();
   if (!D || !D->isCompleteDefinition())
@@ -3311,8 +3311,8 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, 
llvm::DIFile *Unit) {
   llvm_unreachable("type should have been unwrapped!");
 }
 
-llvm::DICompositeType *CGDebugInfo::getOrCreateLimitedType(const RecordType 
*Ty,
-   llvm::DIFile *Unit) 
{
+llvm::DICompositeType *
+CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty) {
   QualType QTy(Ty, 0);
 
   auto *T = cast_or_null(getTypeOrNull(QTy));

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 59fe7929ef88..31fdd6b8ed18 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -603,8 +603,7 @@ class CGDebugInfo {
 
   /// Get the type from the cache or create a new partial type if
   /// necessary.
-  llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty,
-llvm::DIFile *F);
+  llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty);
 
   /// Create type metadata for a source language type.
   llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 4739dd6 - [LoopDeletion] Break backedge of outermost loops when known not taken

2021-01-10 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-10T16:02:33-08:00
New Revision: 4739dd67e7a08b715f1d23f71fb4af16007fe80a

URL: 
https://github.com/llvm/llvm-project/commit/4739dd67e7a08b715f1d23f71fb4af16007fe80a
DIFF: 
https://github.com/llvm/llvm-project/commit/4739dd67e7a08b715f1d23f71fb4af16007fe80a.diff

LOG: [LoopDeletion] Break backedge of outermost loops when known not taken

This is a resubmit of dd6bb367 (which was reverted due to stage2 build failures 
in 7c63aac), with the additional restriction added to the transform to only 
consider outer most loops.

As shown in the added test case, ensuring LCSSA is up to date when deleting an 
inner loop is tricky as we may actually need to remove blocks from any outer 
loops, thus changing the exit block set.   For the moment, just avoid 
transforming this case.  I plan to return to this case in a follow up patch and 
see if we can do better.

Original commit message follows...

The basic idea is that if SCEV can prove the backedge isn't taken, we can go 
ahead and get rid of the backedge (and thus the loop) while leaving the rest of 
the control in place. This nicely handles cases with dispatch between multiple 
exits and internal side effects.

Differential Revision: https://reviews.llvm.org/D93906

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/LoopUtils.h
llvm/lib/Transforms/Scalar/LoopDeletion.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/test/Transforms/IndVarSimplify/exit_value_test2.ll
llvm/test/Transforms/LoopDeletion/update-scev.ll
llvm/test/Transforms/LoopDeletion/zero-btc.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h 
b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index 80c6b09d9cf0..940747b5b2ea 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -179,6 +179,12 @@ bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, 
DominatorTree *,
 void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
 LoopInfo *LI, MemorySSA *MSSA = nullptr);
 
+/// Remove the backedge of the specified loop.  Handles loop nests and general
+/// loop structures subject to the precondition that the loop has no parent
+/// loop and has a single latch block.  Preserves all listed analyses.
+void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
+   LoopInfo &LI, MemorySSA *MSSA);
+
 /// Try to promote memory values to scalars by sinking stores out of
 /// the loop and moving loads to before the loop.  We do this by looping over
 /// the stores in the loop, looking for stores to Must pointers which are

diff  --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp 
b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
index a94676eadeab..bd5cdeabb9bd 100644
--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/LoopUtils.h"
+
 using namespace llvm;
 
 #define DEBUG_TYPE "loop-delete"
@@ -38,6 +39,14 @@ enum class LoopDeletionResult {
   Deleted,
 };
 
+static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B) {
+  if (A == LoopDeletionResult::Deleted || B == LoopDeletionResult::Deleted)
+return LoopDeletionResult::Deleted;
+  if (A == LoopDeletionResult::Modified || B == LoopDeletionResult::Modified)
+return LoopDeletionResult::Modified;
+  return LoopDeletionResult::Unmodified;
+}
+
 /// Determines if a loop is dead.
 ///
 /// This assumes that we've already checked for unique exit and exiting blocks,
@@ -126,6 +135,34 @@ static bool isLoopNeverExecuted(Loop *L) {
   return true;
 }
 
+/// If we can prove the backedge is untaken, remove it.  This destroys the
+/// loop, but leaves the (now trivially loop invariant) control flow and
+/// side effects (if any) in place.
+static LoopDeletionResult
+breakBackedgeIfNotTaken(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
+LoopInfo &LI, MemorySSA *MSSA,
+OptimizationRemarkEmitter &ORE) {
+  assert(L->isLCSSAForm(DT) && "Expected LCSSA!");
+
+  if (!L->getLoopLatch())
+return LoopDeletionResult::Unmodified;
+
+  auto *BTC = SE.getBackedgeTakenCount(L);
+  if (!BTC->isZero())
+return LoopDeletionResult::Unmodified;
+
+  // For non-outermost loops, the tricky case is that we can drop blocks
+  // out of both inner and outer loops at the same time.  This results in
+  // new exiting block for the outer loop appearing, and possibly needing
+  // an lcssa phi inserted.  (See loop_nest_lcssa test case in zero-btc.ll)
+  // TODO: We can handle a bunch of cases here without much work, revisit.
+  if (!L->isOutermost())
+return LoopDeletionResult::Unmodified;
+
+  breakLoopBackedge(L, DT, SE, LI, MSSA)

[llvm-branch-commits] [llvm] d43a264 - Revert "[X86][SSE] Fold unpack(hop(), hop()) -> permute(hop())"

2021-01-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2021-01-10T20:22:53-05:00
New Revision: d43a264a5dd3c72bf9dc663551c0993921b28136

URL: 
https://github.com/llvm/llvm-project/commit/d43a264a5dd3c72bf9dc663551c0993921b28136
DIFF: 
https://github.com/llvm/llvm-project/commit/d43a264a5dd3c72bf9dc663551c0993921b28136.diff

LOG: Revert "[X86][SSE] Fold unpack(hop(),hop()) -> permute(hop())"

This reverts commit 80dee7965dffdfb866afa9d74f3a4a97453708b2.
Makes clang sometimes hang forever. See
https://bugs.chromium.org/p/chromium/issues/detail?id=1164786#c6 for a
stand-alone repro.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/horizontal-shuffle-2.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 7b0e927a33d2..16f1023ed5f8 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -37513,12 +37513,10 @@ static SDValue combineShuffleOfConcatUndef(SDNode *N, 
SelectionDAG &DAG,
 
 /// Eliminate a redundant shuffle of a horizontal math op.
 static SDValue foldShuffleOfHorizOp(SDNode *N, SelectionDAG &DAG) {
-  // TODO: Can we use getTargetShuffleInputs instead?
   unsigned Opcode = N->getOpcode();
   if (Opcode != X86ISD::MOVDDUP && Opcode != X86ISD::VBROADCAST)
-if (Opcode != X86ISD::UNPCKL && Opcode != X86ISD::UNPCKH)
-  if (Opcode != ISD::VECTOR_SHUFFLE || !N->getOperand(1).isUndef())
-return SDValue();
+if (Opcode != ISD::VECTOR_SHUFFLE || !N->getOperand(1).isUndef())
+  return SDValue();
 
   // For a broadcast, peek through an extract element of index 0 to find the
   // horizontal op: broadcast (ext_vec_elt HOp, 0)
@@ -37537,24 +37535,6 @@ static SDValue foldShuffleOfHorizOp(SDNode *N, 
SelectionDAG &DAG) {
   HOp.getOpcode() != X86ISD::HSUB && HOp.getOpcode() != X86ISD::FHSUB)
 return SDValue();
 
-  // unpck(hop,hop) -> permute(hop,hop).
-  if (Opcode == X86ISD::UNPCKL || Opcode == X86ISD::UNPCKH) {
-SDValue HOp2 = N->getOperand(1);
-if (HOp.getOpcode() != HOp2.getOpcode() || VT.getScalarSizeInBits() != 32)
-  return SDValue();
-SDLoc DL(HOp);
-unsigned LoHi = Opcode == X86ISD::UNPCKL ? 0 : 1;
-SDValue Res = DAG.getNode(HOp.getOpcode(), DL, VT, HOp.getOperand(LoHi),
-  HOp2.getOperand(LoHi));
-// Use SHUFPS for the permute so this will work on SSE3 targets, shuffle
-// combining and domain handling will simplify this later on.
-EVT ShuffleVT = VT.changeVectorElementType(MVT::f32);
-Res = DAG.getBitcast(ShuffleVT, Res);
-Res = DAG.getNode(X86ISD::SHUFP, DL, ShuffleVT, Res, Res,
-  getV4X86ShuffleImm8ForMask({0, 2, 1, 3}, DL, DAG));
-return DAG.getBitcast(VT, Res);
-  }
-
   // 128-bit horizontal math instructions are defined to operate on adjacent
   // lanes of each operand as:
   // v4X32: A[0] + A[1] , A[2] + A[3] , B[0] + B[1] , B[2] + B[3]

diff  --git a/llvm/test/CodeGen/X86/horizontal-shuffle-2.ll 
b/llvm/test/CodeGen/X86/horizontal-shuffle-2.ll
index 6b4b8047d0f0..c012c88c6ed2 100644
--- a/llvm/test/CodeGen/X86/horizontal-shuffle-2.ll
+++ b/llvm/test/CodeGen/X86/horizontal-shuffle-2.ll
@@ -9,8 +9,9 @@
 define <4 x float> @test_unpacklo_hadd_v4f32(<4 x float> %0, <4 x float> %1, 
<4 x float> %2, <4 x float> %3) {
 ; CHECK-LABEL: test_unpacklo_hadd_v4f32:
 ; CHECK:   ## %bb.0:
-; CHECK-NEXT:vhaddps %xmm2, %xmm0, %xmm0
-; CHECK-NEXT:vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
+; CHECK-NEXT:vhaddps %xmm0, %xmm0, %xmm0
+; CHECK-NEXT:vhaddps %xmm0, %xmm2, %xmm1
+; CHECK-NEXT:vunpcklps {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
 ; CHECK-NEXT:ret{{[l|q]}}
   %5 = tail call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %0, <4 x 
float> %1) #4
   %6 = tail call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %2, <4 x 
float> %3) #4
@@ -21,8 +22,9 @@ define <4 x float> @test_unpacklo_hadd_v4f32(<4 x float> %0, 
<4 x float> %1, <4
 define <4 x float> @test_unpackhi_hadd_v4f32(<4 x float> %0, <4 x float> %1, 
<4 x float> %2, <4 x float> %3) {
 ; CHECK-LABEL: test_unpackhi_hadd_v4f32:
 ; CHECK:   ## %bb.0:
-; CHECK-NEXT:vhaddps %xmm3, %xmm1, %xmm0
-; CHECK-NEXT:vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
+; CHECK-NEXT:vhaddps %xmm1, %xmm0, %xmm0
+; CHECK-NEXT:vhaddps %xmm3, %xmm0, %xmm1
+; CHECK-NEXT:vunpckhps {{.*#+}} xmm0 = xmm0[2],xmm1[2],xmm0[3],xmm1[3]
 ; CHECK-NEXT:ret{{[l|q]}}
   %5 = tail call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %0, <4 x 
float> %1) #4
   %6 = tail call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %2, <4 x 
float> %3) #4
@@ -33,8 +35,9 @@ define <4 x float> @test_unpackhi_hadd_v4f32(<4 x float> %0, 
<4 x float> %1, <4
 define <4 x float> @test_unpacklo_hsub_v4f32(<4 x float> %0, <4 x float> %1, 
<4 x float> %2, <4 x float> %3) {
 ; CHECK-LABEL: test_unpacklo_hsub_v4f32:
 ; CHECK:

[llvm-branch-commits] [llvm] 7539c75 - [DAGCombine] Remove the check for unsafe-fp-math when we are checking the AFN

2021-01-10 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2021-01-11T02:25:53Z
New Revision: 7539c75bb438f185575573ed4ea8da7cb37d3f2a

URL: 
https://github.com/llvm/llvm-project/commit/7539c75bb438f185575573ed4ea8da7cb37d3f2a
DIFF: 
https://github.com/llvm/llvm-project/commit/7539c75bb438f185575573ed4ea8da7cb37d3f2a.diff

LOG: [DAGCombine] Remove the check for unsafe-fp-math when we are checking the 
AFN

We are checking the unsafe-fp-math for sqrt but not for fpow, which behaves 
inconsistent.
As the direction is to remove this global option, we need to remove the 
unsafe-fp-math
check for sqrt and update the test with afn fast-math flags.

Reviewed By: Spatel

Differential Revision: https://reviews.llvm.org/D93891

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/test/CodeGen/AMDGPU/fneg-combines.ll
llvm/test/CodeGen/AMDGPU/frem.ll
llvm/test/CodeGen/NVPTX/fast-math.ll
llvm/test/CodeGen/NVPTX/sqrt-approx.ll
llvm/test/CodeGen/X86/sqrt-fastmath-mir.ll
llvm/test/CodeGen/X86/sqrt-fastmath.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 09c8f7219390..be57d9250db7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13918,7 +13918,7 @@ SDValue DAGCombiner::visitFSQRT(SDNode *N) {
 
   // Require 'ninf' flag since sqrt(+Inf) = +Inf, but the estimation goes as:
   // sqrt(+Inf) == rsqrt(+Inf) * +Inf = 0 * +Inf = NaN
-  if ((!Options.UnsafeFPMath && !Flags.hasApproximateFuncs()) ||
+  if (!Flags.hasApproximateFuncs() ||
   (!Options.NoInfsFPMath && !Flags.hasNoInfs()))
 return SDValue();
 

diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 23e817eb51cb..e68b4e6c2cd6 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -8172,8 +8172,7 @@ SDValue SITargetLowering::lowerFastUnsafeFDIV(SDValue Op,
   EVT VT = Op.getValueType();
   const SDNodeFlags Flags = Op->getFlags();
 
-  bool AllowInaccurateRcp = DAG.getTarget().Options.UnsafeFPMath ||
-Flags.hasApproximateFuncs();
+  bool AllowInaccurateRcp = Flags.hasApproximateFuncs();
 
   // Without !fpmath accuracy information, we can't do more because we don't
   // know exactly whether rcp is accurate enough to meet !fpmath requirement.

diff  --git a/llvm/test/CodeGen/AMDGPU/fneg-combines.ll 
b/llvm/test/CodeGen/AMDGPU/fneg-combines.ll
index de10dae7ee9f..eaf4232335ec 100644
--- a/llvm/test/CodeGen/AMDGPU/fneg-combines.ll
+++ b/llvm/test/CodeGen/AMDGPU/fneg-combines.ll
@@ -252,7 +252,7 @@ define amdgpu_ps float @fneg_fadd_0(float inreg %tmp2, 
float inreg %tmp6, <4 x i
 ; GCN-NSZ-DAG: v_cmp_nlt_f32_e64 {{.*}}, -[[D]]
 define amdgpu_ps float @fneg_fadd_0_nsz(float inreg %tmp2, float inreg %tmp6, 
<4 x i32> %arg) local_unnamed_addr #2 {
 .entry:
-  %tmp7 = fdiv float 1.00e+00, %tmp6
+  %tmp7 = fdiv afn float 1.00e+00, %tmp6
   %tmp8 = fmul float 0.00e+00, %tmp7
   %tmp9 = fmul reassoc nnan arcp contract float 0.00e+00, %tmp8
   %.i188 = fadd float %tmp9, 0.00e+00

diff  --git a/llvm/test/CodeGen/AMDGPU/frem.ll 
b/llvm/test/CodeGen/AMDGPU/frem.ll
index ef19917cc45f..46974c2f38d3 100644
--- a/llvm/test/CodeGen/AMDGPU/frem.ll
+++ b/llvm/test/CodeGen/AMDGPU/frem.ll
@@ -297,7 +297,7 @@ define amdgpu_kernel void @unsafe_frem_f16(half 
addrspace(1)* %out, half addrspa
%gep2 = getelementptr half, half addrspace(1)* %in2, i32 4
%r0 = load half, half addrspace(1)* %in1, align 4
%r1 = load half, half addrspace(1)* %gep2, align 4
-   %r2 = frem half %r0, %r1
+   %r2 = frem afn half %r0, %r1
store half %r2, half addrspace(1)* %out, align 4
ret void
 }
@@ -576,7 +576,7 @@ define amdgpu_kernel void @unsafe_frem_f32(float 
addrspace(1)* %out, float addrs
%gep2 = getelementptr float, float addrspace(1)* %in2, i32 4
%r0 = load float, float addrspace(1)* %in1, align 4
%r1 = load float, float addrspace(1)* %gep2, align 4
-   %r2 = frem float %r0, %r1
+   %r2 = frem afn float %r0, %r1
store float %r2, float addrspace(1)* %out, align 4
ret void
 }
@@ -924,7 +924,7 @@ define amdgpu_kernel void @unsafe_frem_f64(double 
addrspace(1)* %out, double add
  double addrspace(1)* %in2) #1 {
%r0 = load double, double addrspace(1)* %in1, align 8
%r1 = load double, double addrspace(1)* %in2, align 8
-   %r2 = frem double %r0, %r1
+   %r2 = frem afn double %r0, %r1
store double %r2, double addrspace(1)* %out, align 8
ret void
 }

diff  --git a/llvm/test/CodeGen/NVPTX/fast-math.ll 
b/llvm/test/CodeGen/NVPTX/fast-math.ll
index db5fb63f4e76..1f300fecb131 100644
--- a/llvm/test/CodeGen/NVPTX/fast-math.ll
+++ b/llvm/test/CodeGen/NVPTX/fast-math.ll
@@ -25,7 +25,7 @@ def

[llvm-branch-commits] [llvm] 5cf73dc - [RISCV] Convert most of the information about RVV Pseudos into bits in TSFlags.

2021-01-10 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-10T19:15:45-08:00
New Revision: 5cf73dca77e52f54c893d2c5fc2f56a5f2764f7d

URL: 
https://github.com/llvm/llvm-project/commit/5cf73dca77e52f54c893d2c5fc2f56a5f2764f7d
DIFF: 
https://github.com/llvm/llvm-project/commit/5cf73dca77e52f54c893d2c5fc2f56a5f2764f7d.diff

LOG: [RISCV] Convert most of the information about RVV Pseudos into bits in 
TSFlags.

This patch moves all but the BaseInstr to bits in TSFlags.

For the index fields, we can just use a bit to indicate their presence.
The locations of the operands are well defined.

This reduces the llc binary by about 32K on my build. It also
removes the binary search of the table from the custom inserter.
Instead we just check that the SEW op is present.

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D94375

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrFormats.td
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 22d15bc8586b..2349b43f30c6 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -2122,7 +2122,7 @@ static MachineBasicBlock *emitSelectPseudo(MachineInstr 
&MI,
 
 static MachineBasicBlock *addVSetVL(MachineInstr &MI, MachineBasicBlock *BB,
 int VLIndex, unsigned SEWIndex,
-unsigned VLMul, bool WritesElement0) {
+RISCVVLMUL VLMul, bool WritesElement0) {
   MachineFunction &MF = *BB->getParent();
   DebugLoc DL = MI.getDebugLoc();
   const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
@@ -2131,9 +2131,6 @@ static MachineBasicBlock *addVSetVL(MachineInstr &MI, 
MachineBasicBlock *BB,
   assert(RISCVVType::isValidSEW(SEW) && "Unexpected SEW");
   RISCVVSEW ElementWidth = static_cast(Log2_32(SEW / 8));
 
-  // LMUL should already be encoded correctly.
-  RISCVVLMUL Multiplier = static_cast(VLMul);
-
   MachineRegisterInfo &MRI = MF.getRegInfo();
 
   // VL and VTYPE are alive here.
@@ -2160,7 +2157,7 @@ static MachineBasicBlock *addVSetVL(MachineInstr &MI, 
MachineBasicBlock *BB,
 TailAgnostic = false;
 
   // For simplicity we reuse the vtype representation here.
-  MIB.addImm(RISCVVType::encodeVTYPE(Multiplier, ElementWidth,
+  MIB.addImm(RISCVVType::encodeVTYPE(VLMul, ElementWidth,
  /*TailAgnostic*/ TailAgnostic,
  /*MaskAgnostic*/ false));
 
@@ -2177,15 +2174,17 @@ static MachineBasicBlock *addVSetVL(MachineInstr &MI, 
MachineBasicBlock *BB,
 MachineBasicBlock *
 RISCVTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
  MachineBasicBlock *BB) const {
+  uint64_t TSFlags = MI.getDesc().TSFlags;
 
-  if (const RISCVVPseudosTable::PseudoInfo *RVV =
-  RISCVVPseudosTable::getPseudoInfo(MI.getOpcode())) {
-int VLIndex = RVV->getVLIndex();
-int SEWIndex = RVV->getSEWIndex();
-bool WritesElement0 = RVV->writesElement0();
+  if (TSFlags & RISCVII::HasSEWOpMask) {
+unsigned NumOperands = MI.getNumExplicitOperands();
+int VLIndex = (TSFlags & RISCVII::HasVLOpMask) ? NumOperands - 2 : -1;
+unsigned SEWIndex = NumOperands - 1;
+bool WritesElement0 = TSFlags & RISCVII::WritesElement0Mask;
 
-assert(SEWIndex >= 0 && "SEWIndex must be >= 0");
-return addVSetVL(MI, BB, VLIndex, SEWIndex, RVV->VLMul, WritesElement0);
+RISCVVLMUL VLMul = static_cast((TSFlags & RISCVII::VLMulMask) 
>>
+   RISCVII::VLMulShift);
+return addVSetVL(MI, BB, VLIndex, SEWIndex, VLMul, WritesElement0);
   }
 
   switch (MI.getOpcode()) {

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrFormats.td 
b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
index 5c8d8fa65b30..ea867c549e64 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrFormats.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
@@ -167,6 +167,24 @@ class RVInst VLMul = 0;
+  let TSFlags{10-8} = VLMul;
+
+  bit HasDummyMask = 0;
+  let TSFlags{11} = HasDummyMask;
+
+  bit WritesElement0 = 0;
+  let TSFlags{12} = WritesElement0;
+
+  bit HasMergeOp = 0;
+  let TSFlags{13} = HasMergeOp;
+
+  bit HasSEWOp = 0;
+  let TSFlags{14} = HasSEWOp;
+
+  bit HasVLOp = 0;
+  let TSFlags{15} = HasVLOp;
 }
 
 // Pseudo instructions

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index ac179619db61..8f494d54ee64 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -330,20 +330,13 @@ def InvalidIndex : CONST8b<0x80

[llvm-branch-commits] [llvm] 7f69860 - [LoopUnroll] Fix a crash

2021-01-10 Thread Serguei Katkov via llvm-branch-commits

Author: Serguei Katkov
Date: 2021-01-11T10:19:26+07:00
New Revision: 7f69860243e8933c3da1177afde0d3cb6544d04e

URL: 
https://github.com/llvm/llvm-project/commit/7f69860243e8933c3da1177afde0d3cb6544d04e
DIFF: 
https://github.com/llvm/llvm-project/commit/7f69860243e8933c3da1177afde0d3cb6544d04e.diff

LOG: [LoopUnroll] Fix a crash

Loop peeling as a last step triggers loop simplification and this
can change the loop structure. As a result all cashed values like
latch branch becomes invalid.

Patch re-structure the code to take into account the possible
changes caused by peeling.

Reviewers: dmgreen, Meinersbur, etiotto, fhahn, efriedma, bmahjour
Reviewed By: Meinersbur, fhahn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D93686

Added: 
llvm/test/Transforms/LoopUnroll/unroll-after-peel.ll

Modified: 
llvm/lib/Transforms/Utils/LoopUnroll.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp 
b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 4d5d03528633..6478143545ab 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -288,14 +288,12 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, 
UnrollLoopOptions ULO, LoopInfo *LI,
   OptimizationRemarkEmitter *ORE,
   bool PreserveLCSSA, Loop **RemainderLoop) {
 
-  BasicBlock *Preheader = L->getLoopPreheader();
-  if (!Preheader) {
+  if (!L->getLoopPreheader()) {
 LLVM_DEBUG(dbgs() << "  Can't unroll; loop preheader-insertion failed.\n");
 return LoopUnrollResult::Unmodified;
   }
 
-  BasicBlock *LatchBlock = L->getLoopLatch();
-  if (!LatchBlock) {
+  if (!L->getLoopLatch()) {
 LLVM_DEBUG(dbgs() << "  Can't unroll; loop exit-block-insertion 
failed.\n");
 return LoopUnrollResult::Unmodified;
   }
@@ -306,37 +304,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, 
UnrollLoopOptions ULO, LoopInfo *LI,
 return LoopUnrollResult::Unmodified;
   }
 
-  // The current loop unroll pass can unroll loops that have
-  // (1) single latch; and
-  // (2a) latch is unconditional; or
-  // (2b) latch is conditional and is an exiting block
-  // FIXME: The implementation can be extended to work with more complicated
-  // cases, e.g. loops with multiple latches.
-  BasicBlock *Header = L->getHeader();
-  BranchInst *LatchBI = dyn_cast(LatchBlock->getTerminator());
-
-  // A conditional branch which exits the loop, which can be optimized to an
-  // unconditional branch in the unrolled loop in some cases.
-  BranchInst *ExitingBI = nullptr;
-  bool LatchIsExiting = L->isLoopExiting(LatchBlock);
-  if (LatchIsExiting)
-ExitingBI = LatchBI;
-  else if (BasicBlock *ExitingBlock = L->getExitingBlock())
-ExitingBI = dyn_cast(ExitingBlock->getTerminator());
-  if (!LatchBI || (LatchBI->isConditional() && !LatchIsExiting)) {
-LLVM_DEBUG(
-dbgs() << "Can't unroll; a conditional latch must exit the loop");
-return LoopUnrollResult::Unmodified;
-  }
-  LLVM_DEBUG({
-if (ExitingBI)
-  dbgs() << "  Exiting Block = " << ExitingBI->getParent()->getName()
- << "\n";
-else
-  dbgs() << "  No single exiting block\n";
-  });
-
-  if (Header->hasAddressTaken()) {
+  if (L->getHeader()->hasAddressTaken()) {
 // The loop-rotate pass can be helpful to avoid this in many cases.
 LLVM_DEBUG(
 dbgs() << "  Won't unroll loop: address of header block is taken.\n");
@@ -365,20 +333,6 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, 
UnrollLoopOptions ULO, LoopInfo *LI,
 
   // Are we eliminating the loop control altogether?
   bool CompletelyUnroll = ULO.Count == ULO.TripCount;
-  SmallVector ExitBlocks;
-  L->getExitBlocks(ExitBlocks);
-  std::vector OriginalLoopBlocks = L->getBlocks();
-
-  // Go through all exits of L and see if there are any phi-nodes there. We 
just
-  // conservatively assume that they're inserted to preserve LCSSA form, which
-  // means that complete unrolling might break this form. We need to either fix
-  // it in-place after the transformation, or entirely rebuild LCSSA. TODO: For
-  // now we just recompute LCSSA for the outer loop, but it should be possible
-  // to fix it in-place.
-  bool NeedToFixLCSSA = PreserveLCSSA && CompletelyUnroll &&
-any_of(ExitBlocks, [](const BasicBlock *BB) {
-  return isa(BB->begin());
-});
 
   // We assume a run-time trip count if the compiler cannot
   // figure out the loop trip count and the unroll-runtime
@@ -403,12 +357,63 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, 
UnrollLoopOptions ULO, LoopInfo *LI,
   BasicBlock *ExitingBlock = L->getLoopLatch();
   assert(ExitingBlock && "Loop without exiting block?");
   assert(L->isLoopExiting(ExitingBlock) && "Latch is not exiting?");
-  Preheader = L->getLoopPreheader();
   ULO.Tr

[llvm-branch-commits] [clang] ffa6787 - [PowerPC] Add variants of 64-bit vector types for vec_sel.

2021-01-10 Thread via llvm-branch-commits

Author: Esme-Yi
Date: 2021-01-11T03:52:16Z
New Revision: ffa67873a3f93a6baa0046221edd08a90b0db6f8

URL: 
https://github.com/llvm/llvm-project/commit/ffa67873a3f93a6baa0046221edd08a90b0db6f8
DIFF: 
https://github.com/llvm/llvm-project/commit/ffa67873a3f93a6baa0046221edd08a90b0db6f8.diff

LOG: [PowerPC] Add variants of 64-bit vector types for vec_sel.

Summary: This patch added variants of vec_sel and fixed bugzilla 46770.

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D94162

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 2b82113de311..4d50d47d51b5 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -8281,6 +8281,46 @@ vec_sel(vector double __a, vector double __b, vector 
unsigned long long __c) {
((vector long long)__b & (vector long long)__c);
   return (vector double)__res;
 }
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_sel(vector bool long long __a, vector bool long long __b,
+vector bool long long __c) {
+  return (__a & ~__c) | (__b & __c);
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_sel(vector bool long long __a, vector bool long long __b,
+vector unsigned long long __c) {
+  return (__a & ~(vector bool long long)__c) |
+ (__b & (vector bool long long)__c);
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_sel(vector signed long long __a, vector signed long long __b,
+vector bool long long __c) {
+  return (__a & ~(vector signed long long)__c) |
+ (__b & (vector signed long long)__c);
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_sel(vector signed long long __a, vector signed long long __b,
+vector unsigned long long __c) {
+  return (__a & ~(vector signed long long)__c) |
+ (__b & (vector signed long long)__c);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_sel(vector unsigned long long __a, vector unsigned long long __b,
+vector bool long long __c) {
+  return (__a & ~(vector unsigned long long)__c) |
+ (__b & (vector unsigned long long)__c);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_sel(vector unsigned long long __a, vector unsigned long long __b,
+vector unsigned long long __c) {
+  return (__a & ~__c) | (__b & __c);
+}
 #endif
 
 /* vec_vsel */

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index cb9d484b5a77..bd0e66e69800 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -928,6 +928,66 @@ void test1() {
 // CHECK-LE: or <2 x i64>
 // CHECK-LE: bitcast <2 x i64> %{{[0-9]+}} to <2 x double>
 
+  res_vbll = vec_sel(vbll, vbll, vbll);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[0-9]+}},
+// CHECK-LE: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK-LE: or <2 x i64>
+
+  res_vbll = vec_sel(vbll, vbll, vull);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[0-9]+}},
+// CHECK-LE: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK-LE: or <2 x i64>
+
+  res_vsll = vec_sel(vsll, vsll, vbll);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[0-9]+}},
+// CHECK-LE: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK-LE: or <2 x i64>
+
+  res_vsll = vec_sel(vsll, vsll, vull);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[0-9]+}},
+// CHECK-LE: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK-LE: or <2 x i64>
+
+  res_vull = vec_sel(vull, vull, vbll);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[0-9]+}},
+// CHECK-LE: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK-LE: or <2 x i64>
+
+  res_vull = vec_sel(vull, vull, vull);
+// CHECK: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK: and <2 x i64> %{{[0-9]+}},
+// CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}}
+// CHECK: or <2 x i64>
+// CHECK-LE: xor <2 x i64> %{{[0-9]+}}, 
+// CHECK-LE: and <2 x i64> %{{[

[llvm-branch-commits] [mlir] dcac2da - [IR Parser] Fix a crash handling zero width integer attributes.

2021-01-10 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2021-01-10T21:18:01-08:00
New Revision: dcac2da10632c83737fce6da60fbc4dd09c01034

URL: 
https://github.com/llvm/llvm-project/commit/dcac2da10632c83737fce6da60fbc4dd09c01034
DIFF: 
https://github.com/llvm/llvm-project/commit/dcac2da10632c83737fce6da60fbc4dd09c01034.diff

LOG: [IR Parser] Fix a crash handling zero width integer attributes.

llvm::APInt cannot hold zero bit values, therefore we shouldn't try
to form them.

Differential Revision: https://reviews.llvm.org/D94384

Added: 


Modified: 
mlir/lib/Parser/AttributeParser.cpp
mlir/test/IR/invalid-ops.mlir

Removed: 




diff  --git a/mlir/lib/Parser/AttributeParser.cpp 
b/mlir/lib/Parser/AttributeParser.cpp
index e78237e8e5a0..859e8e279917 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -334,6 +334,11 @@ static Optional buildAttributeAPInt(Type type, bool 
isNegative,
   // Extend or truncate the bitwidth to the right size.
   unsigned width = type.isIndex() ? IndexType::kInternalStorageBitWidth
   : type.getIntOrFloatBitWidth();
+
+  // APInt cannot hold a zero bit value.
+  if (width == 0)
+return llvm::None;
+
   if (width > result.getBitWidth()) {
 result = result.zext(width);
   } else if (width < result.getBitWidth()) {

diff  --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir
index 595e3fe3f123..ff39611eaea1 100644
--- a/mlir/test/IR/invalid-ops.mlir
+++ b/mlir/test/IR/invalid-ops.mlir
@@ -1252,3 +1252,11 @@ func @subtensor_wrong_static_type(%t: 
tensor<8x16x4xf32>, %idx : index) {
 
   return
 }
+
+// -
+
+func @no_zero_bit_integer_attrs() {
+  // expected-error @+1 {{integer constant out of range for attribute}}
+  %x = "some.op"(){value = 0 : i0} : () -> f32
+  return
+}
\ No newline at end of file



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 6215c1b - CGDebugInfo: Delete redundant test

2021-01-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-10T22:22:06-08:00
New Revision: 6215c1b778f62433f3d79addc299a1bbd0e524d0

URL: 
https://github.com/llvm/llvm-project/commit/6215c1b778f62433f3d79addc299a1bbd0e524d0
DIFF: 
https://github.com/llvm/llvm-project/commit/6215c1b778f62433f3d79addc299a1bbd0e524d0.diff

LOG: CGDebugInfo: Delete redundant test

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 74ec683fe6e5..df8432d47bde 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3148,8 +3148,6 @@ llvm::DIType *CGDebugInfo::getTypeOrNull(QualType Ty) {
 
 void CGDebugInfo::completeTemplateDefinition(
 const ClassTemplateSpecializationDecl &SD) {
-  if (DebugKind <= codegenoptions::DebugLineTablesOnly)
-return;
   completeUnusedClass(SD);
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] b8d2842 - CGDebugInfo: Delete unneeded UnwrapTypeForDebugInfo

2021-01-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-10T22:22:07-08:00
New Revision: b8d28420885a42d16a57e02c28129d0eb92474a1

URL: 
https://github.com/llvm/llvm-project/commit/b8d28420885a42d16a57e02c28129d0eb92474a1
DIFF: 
https://github.com/llvm/llvm-project/commit/b8d28420885a42d16a57e02c28129d0eb92474a1.diff

LOG: CGDebugInfo: Delete unneeded UnwrapTypeForDebugInfo

Tested with stage 2 -DCMAKE_BUILD_TYPE=Debug clang, byte identical.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index df8432d47bde..7dc6457d08d0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3132,10 +3132,6 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const 
ASTContext &C) {
 }
 
 llvm::DIType *CGDebugInfo::getTypeOrNull(QualType Ty) {
-
-  // Unwrap the type as needed for debug information.
-  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
-
   auto It = TypeCache.find(Ty.getAsOpaquePtr());
   if (It != TypeCache.end()) {
 // Verify that the debug info still exists.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] a40767e - [MLIR][SPIRV] Add (de-)serialization support for SpecConstantOpeation.

2021-01-10 Thread via llvm-branch-commits

Author: ergawy
Date: 2021-01-11T07:37:50+01:00
New Revision: a40767ec8851b997e4dcc9987078bd02670f8c7f

URL: 
https://github.com/llvm/llvm-project/commit/a40767ec8851b997e4dcc9987078bd02670f8c7f
DIFF: 
https://github.com/llvm/llvm-project/commit/a40767ec8851b997e4dcc9987078bd02670f8c7f.diff

LOG: [MLIR][SPIRV] Add (de-)serialization support for SpecConstantOpeation.

This commit adds support for (de-)serializing SpecConstantOpeation. One
thing worth noting is that during deserialization, we assign a fake ID to
enclosed ops inside SpecConstantOpeation. We need to do this in order
for deserialization logic to properly update ID to value map and to
later reference the created value from the sibling 'spv::YieldOp'.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D93591

Added: 


Modified: 
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
mlir/lib/Target/SPIRV/Deserialization.cpp
mlir/lib/Target/SPIRV/Serialization.cpp
mlir/test/Dialect/SPIRV/IR/structure-ops.mlir
mlir/test/Target/SPIRV/spec-constant.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td 
b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
index 76374ca481fb..99b245563ca6 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
@@ -3170,6 +3170,7 @@ def SPV_OC_OpSpecConstantTrue  : 
I32EnumAttrCase<"OpSpecConstantTrue", 4
 def SPV_OC_OpSpecConstantFalse : 
I32EnumAttrCase<"OpSpecConstantFalse", 49>;
 def SPV_OC_OpSpecConstant  : I32EnumAttrCase<"OpSpecConstant", 50>;
 def SPV_OC_OpSpecConstantComposite : 
I32EnumAttrCase<"OpSpecConstantComposite", 51>;
+def SPV_OC_OpSpecConstantOperation : 
I32EnumAttrCase<"OpSpecConstantOperation", 52>;
 def SPV_OC_OpFunction  : I32EnumAttrCase<"OpFunction", 54>;
 def SPV_OC_OpFunctionParameter : 
I32EnumAttrCase<"OpFunctionParameter", 55>;
 def SPV_OC_OpFunctionEnd   : I32EnumAttrCase<"OpFunctionEnd", 56>;
@@ -3314,7 +3315,8 @@ def SPV_OpcodeAttr :
   SPV_OC_OpConstantTrue, SPV_OC_OpConstantFalse, SPV_OC_OpConstant,
   SPV_OC_OpConstantComposite, SPV_OC_OpConstantNull, 
SPV_OC_OpSpecConstantTrue,
   SPV_OC_OpSpecConstantFalse, SPV_OC_OpSpecConstant,
-  SPV_OC_OpSpecConstantComposite, SPV_OC_OpFunction, 
SPV_OC_OpFunctionParameter,
+  SPV_OC_OpSpecConstantComposite, SPV_OC_OpSpecConstantOperation,
+  SPV_OC_OpFunction, SPV_OC_OpFunctionParameter,
   SPV_OC_OpFunctionEnd, SPV_OC_OpFunctionCall, SPV_OC_OpVariable, 
SPV_OC_OpLoad,
   SPV_OC_OpStore, SPV_OC_OpCopyMemory, SPV_OC_OpAccessChain, 
SPV_OC_OpDecorate,
   SPV_OC_OpMemberDecorate, SPV_OC_OpVectorExtractDynamic,

diff  --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp 
b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index ad3e78f618b7..c90895197f43 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -3445,9 +3445,8 @@ static LogicalResult 
verify(spirv::SpecConstantOperationOp constOp) {
 return constOp.emitOpError("invalid enclosed op");
 
   for (auto operand : enclosedOp.getOperands())
-if (!isa(
-operand.getDefiningOp()))
+if (!isa(operand.getDefiningOp()))
   return constOp.emitOpError(
   "invalid operand, must be defined by a constant operation");
 

diff  --git a/mlir/lib/Target/SPIRV/Deserialization.cpp 
b/mlir/lib/Target/SPIRV/Deserialization.cpp
index 30f46f6fc605..07eb3d35e0a4 100644
--- a/mlir/lib/Target/SPIRV/Deserialization.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization.cpp
@@ -13,6 +13,7 @@
 #include "mlir/Target/SPIRV/Deserialization.h"
 
 #include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
 #include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
 #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
@@ -28,6 +29,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/bit.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace mlir;
@@ -132,6 +134,14 @@ struct DeferredStructTypeInfo {
   SmallVector 
memberDecorationsInfo;
 };
 
+/// A struct that collects the info needed to materialize/emit a
+/// SpecConstantOperation op.
+struct SpecConstOperationMaterializationInfo {
+  spirv::Opcode enclodesOpcode;
+  uint32_t resultTypeID;
+  SmallVector enclosedOpOperands;
+};
+
 
//===--===//
 // Deserializer Declaration
 
//===--===//
@@ -216,9 +226,14 @@ class Deserializer {
   /// Gets the constant's attribute and type associated with the given .
   Optional> getConstant(uint32_t id);
 
-  /// Gets the constant's integer

[llvm-branch-commits] [llvm] 5e47606 - [NFC][AsmPrinter] Make comments for spill/reload more precise.

2021-01-10 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2021-01-11T15:00:27+08:00
New Revision: 5e476061deb82ed4e6d440445f8830e1c7bccaa6

URL: 
https://github.com/llvm/llvm-project/commit/5e476061deb82ed4e6d440445f8830e1c7bccaa6
DIFF: 
https://github.com/llvm/llvm-project/commit/5e476061deb82ed4e6d440445f8830e1c7bccaa6.diff

LOG: [NFC][AsmPrinter] Make comments for spill/reload more precise.

The size of spill/reload may be unknown for scalable vector types.
When the size is unknown, print it as "Unknown-size" instead of a very
large number.

Differential Revision: https://reviews.llvm.org/D94299

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index d72a91825061..f4749f8ca95d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/EHPersonalities.h"
+#include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/COFF.h"
 #include "llvm/BinaryFormat/Dwarf.h"
@@ -844,13 +845,21 @@ static void emitComments(const MachineInstr &MI, 
raw_ostream &CommentOS) {
   if ((Size = MI.getRestoreSize(TII))) {
 CommentOS << *Size << "-byte Reload\n";
   } else if ((Size = MI.getFoldedRestoreSize(TII))) {
-if (*Size)
-  CommentOS << *Size << "-byte Folded Reload\n";
+if (*Size) {
+  if (*Size == static_cast(MemoryLocation::UnknownSize))
+CommentOS << "Unknown-size Folded Reload\n";
+  else
+CommentOS << *Size << "-byte Folded Reload\n";
+}
   } else if ((Size = MI.getSpillSize(TII))) {
 CommentOS << *Size << "-byte Spill\n";
   } else if ((Size = MI.getFoldedSpillSize(TII))) {
-if (*Size)
-  CommentOS << *Size << "-byte Folded Spill\n";
+if (*Size) {
+  if (*Size == static_cast(MemoryLocation::UnknownSize))
+CommentOS << "Unknown-size Folded Spill\n";
+  else
+CommentOS << *Size << "-byte Folded Spill\n";
+}
   }
 
   // Check for spill-induced copies



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 7b11f56 - [JITLink] Rename PostAllocationPasses to PreFixupPasses.

2021-01-10 Thread Lang Hames via llvm-branch-commits

Author: Lang Hames
Date: 2021-01-11T18:33:50+11:00
New Revision: 7b11f564dcfc867c3e7a2075e8a943014fe30780

URL: 
https://github.com/llvm/llvm-project/commit/7b11f564dcfc867c3e7a2075e8a943014fe30780
DIFF: 
https://github.com/llvm/llvm-project/commit/7b11f564dcfc867c3e7a2075e8a943014fe30780.diff

LOG: [JITLink] Rename PostAllocationPasses to PreFixupPasses.

PreFixupPasses better reflects when these passes will run.

A future patch will (re)introduce a PostAllocationPasses list that will run
after allocation, but before JITLinkContext::notifyResolved is called to notify
the rest of the JIT about the resolved symbol addresses.

Added: 


Modified: 
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp

Removed: 




diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h 
b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 6de0cd589aad..72daf76b501a 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -1227,11 +1227,11 @@ struct PassConfiguration {
   ///
   /// These passes are called on the graph after memory has been allocated,
   /// content copied into working memory, and nodes have been assigned their
-  /// final addresses.
+  /// final addresses, but before any fixups have been applied.
   ///
   /// Notable use cases: Late link-time optimizations like GOT and stub
   /// elimination.
-  LinkGraphPassList PostAllocationPasses;
+  LinkGraphPassList PreFixupPasses;
 
   /// Post-fixup passes.
   ///

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp 
b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index ea05b6c7e638..f3a150d23737 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -679,7 +679,7 @@ void link_ELF_x86_64(std::unique_ptr G,
   });
 
   // Add GOT/Stubs optimizer pass.
-  Config.PostAllocationPasses.push_back(optimizeELF_x86_64_GOTAndStubs);
+  Config.PreFixupPasses.push_back(optimizeELF_x86_64_GOTAndStubs);
 
   if (auto Err = Ctx->modifyPassConfig(G->getTargetTriple(), Config))
 return Ctx->notifyFailed(std::move(Err));

diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp 
b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
index f29f6592e6ff..d6ad364add12 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
@@ -114,7 +114,7 @@ void 
JITLinkerBase::linkPhase2(std::unique_ptr Self,
 dumpGraph(dbgs());
   });
 
-  if (auto Err = runPasses(Passes.PostAllocationPasses))
+  if (auto Err = runPasses(Passes.PreFixupPasses))
 return deallocateAndBailOut(std::move(Err));
 
   LLVM_DEBUG({

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp 
b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
index 34e0c3250495..e32bf847014b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -685,7 +685,7 @@ void link_MachO_x86_64(std::unique_ptr G,
 });
 
 // Add GOT/Stubs optimizer pass.
-Config.PostAllocationPasses.push_back(optimizeMachO_x86_64_GOTAndStubs);
+Config.PreFixupPasses.push_back(optimizeMachO_x86_64_GOTAndStubs);
   }
 
   if (auto Err = Ctx->modifyPassConfig(G->getTargetTriple(), Config))



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 131ce83 - [RISCV] Clear isCodeGenOnly flag on VMSGE(U) pseudo instructions. Remove InstAliases that duplicate the asm strings in the pseudos.

2021-01-10 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-10T23:39:08-08:00
New Revision: 131ce834e4bbe443a0da0e0ce00c8d0fa4412458

URL: 
https://github.com/llvm/llvm-project/commit/131ce834e4bbe443a0da0e0ce00c8d0fa4412458
DIFF: 
https://github.com/llvm/llvm-project/commit/131ce834e4bbe443a0da0e0ce00c8d0fa4412458.diff

LOG: [RISCV] Clear isCodeGenOnly flag on VMSGE(U) pseudo instructions. Remove 
InstAliases that duplicate the asm strings in the pseudos.

The Pseudo class sets isCodeGenOnly=1 which causes the asm strings
in the pseudos to be ignored. I think this is why the aliases are
needed at all.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D94024

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoV.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
index 339bb68e6601..aa505b22afd8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
@@ -628,7 +628,8 @@ def PseudoVMSLT_VI : Pseudo<(outs VR:$vd),
 [], "vmslt.vi", "$vd, $vs2, $imm$vm">;
 }
 
-let isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
+let isCodeGenOnly = 0, isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0,
+mayStore = 0 in {
 def PseudoVMSGEU_VX : Pseudo<(outs VR:$vd),
  (ins VR:$vs2, GPR:$rs1),
  [], "vmsgeu.vx", "$vd, $vs2, $rs1">;
@@ -649,25 +650,6 @@ def PseudoVMSGE_VX_M_T : Pseudo<(outs VMV0:$vd, 
VR:$scratch),
 [], "vmsge.vx", "$vd, $vs2, $rs1$vm, 
$scratch">;
 }
 
-// This apparently unnecessary alias prevents matching `vmsge{u}.vx vd, vs2, 
vs1` as if
-// it were an unmasked (i.e. $vm = RISCV::NoRegister) PseudoVMSGE{U}_VX_M.
-def : InstAlias<"vmsgeu.vx $vd, $va, $rs1",
-(PseudoVMSGEU_VX VR:$vd, VR:$va, GPR:$rs1), 0>;
-def : InstAlias<"vmsge.vx $vd, $va, $rs1",
-(PseudoVMSGE_VX VR:$vd, VR:$va, GPR:$rs1), 0>;
-def : InstAlias<"vmsgeu.vx v0, $va, $rs1, $vm, $vt",
-(PseudoVMSGEU_VX_M_T V0, VR:$vt, VR:$va, GPR:$rs1,
- VMaskOp:$vm), 0>;
-def : InstAlias<"vmsge.vx v0, $va, $rs1, $vm, $vt",
-(PseudoVMSGE_VX_M_T V0, VR:$vt, VR:$va, GPR:$rs1,
-VMaskOp:$vm), 0>;
-def : InstAlias<"vmsgeu.vx $vd, $va, $rs1, $vm",
-(PseudoVMSGEU_VX_M VRNoV0:$vd, VR:$va, GPR:$rs1,
-   VMaskOp:$vm), 0>;
-def : InstAlias<"vmsge.vx $vd, $va, $rs1, $vm",
-(PseudoVMSGE_VX_M VRNoV0:$vd, VR:$va, GPR:$rs1,
-  VMaskOp:$vm), 0>;
-
 // Vector Integer Min/Max Instructions
 defm VMINU_V : VALU_IV_V_X<"vminu", 0b000100>;
 defm VMIN_V : VALU_IV_V_X<"vmin", 0b000101>;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] af339f8 - Remove redundant casts.

2021-01-10 Thread Adrian Kuegel via llvm-branch-commits

Author: Adrian Kuegel
Date: 2021-01-11T08:51:47+01:00
New Revision: af339f89a142622b6fc56c5f79d19e568af5287a

URL: 
https://github.com/llvm/llvm-project/commit/af339f89a142622b6fc56c5f79d19e568af5287a
DIFF: 
https://github.com/llvm/llvm-project/commit/af339f89a142622b6fc56c5f79d19e568af5287a.diff

LOG: Remove redundant casts.

Differential Revision: https://reviews.llvm.org/D94305

Added: 


Modified: 
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp

Removed: 




diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp 
b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 8023a8009758..53ebd6721863 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1735,19 +1735,18 @@ struct CreateComplexOpLowering
   using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
 
   LogicalResult
-  matchAndRewrite(CreateComplexOp op, ArrayRef operands,
+  matchAndRewrite(CreateComplexOp complexOp, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const override {
-auto complexOp = cast(op);
 CreateComplexOp::Adaptor transformed(operands);
 
 // Pack real and imaginary part in a complex number struct.
-auto loc = op.getLoc();
+auto loc = complexOp.getLoc();
 auto structType = typeConverter->convertType(complexOp.getType());
 auto complexStruct = ComplexStructBuilder::undef(rewriter, loc, 
structType);
 complexStruct.setReal(rewriter, loc, transformed.real());
 complexStruct.setImaginary(rewriter, loc, transformed.imaginary());
 
-rewriter.replaceOp(op, {complexStruct});
+rewriter.replaceOp(complexOp, {complexStruct});
 return success();
   }
 };
@@ -1794,8 +1793,7 @@ template 
 BinaryComplexOperands
 unpackBinaryComplexOperands(OpTy op, ArrayRef operands,
 ConversionPatternRewriter &rewriter) {
-  auto bop = cast(op);
-  auto loc = bop.getLoc();
+  auto loc = op.getLoc();
   typename OpTy::Adaptor transformed(operands);
 
   // Extract real and imaginary values from operands.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits