[llvm-branch-commits] [llvm] d58512b - [SLP] Don't vectorize stores of non-packed types (like i1, i2)

2021-01-14 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-14T11:30:33+01:00
New Revision: d58512b2e31a255dccc2c9a351a4e47b2b4c9f79

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

LOG: [SLP] Don't vectorize stores of non-packed types (like i1, i2)

In the spirit of commit fc783e91e0c0696e (llvm-svn: 248943) we
shouldn't vectorize stores of non-packed types (i.e. types that
has padding between consecutive variables in a scalar layout,
but being packed in a vector layout).

The problem was detected as a miscompile in a downstream test case.

Reviewed By: anton-afanasyev

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b3a3d65d3340..0f3f74b63860 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3094,6 +3094,16 @@ void BoUpSLP::buildTree_rec(ArrayRef VL, 
unsigned Depth,
 case Instruction::Store: {
   // Check if the stores are consecutive or if we need to swizzle them.
   llvm::Type *ScalarTy = 
cast(VL0)->getValueOperand()->getType();
+  // Avoid types that are padded when being allocated as scalars, while
+  // being packed together in a vector (such as i1).
+  if (DL->getTypeSizeInBits(ScalarTy) !=
+  DL->getTypeAllocSizeInBits(ScalarTy)) {
+BS.cancelScheduling(VL, VL0);
+newTreeEntry(VL, None /*not vectorized*/, S, UserTreeIdx,
+ ReuseShuffleIndicies);
+LLVM_DEBUG(dbgs() << "SLP: Gathering stores of non-packed type.\n");
+return;
+  }
   // Make sure all stores in the bundle are simple - we can't vectorize
   // atomic or volatile stores.
   SmallVector PointerOps(VL.size());

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
index 93a97c3c2405..8c0b9b184130 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
@@ -113,7 +113,6 @@ declare void @f(i64, i64)
 
 define void @test4(i32 %a, i28* %ptr) {
 ; Check that we do not vectorize types that are padded to a bigger ones.
-; FIXME: This is not correct! See D94446.
 ;
 ; CHECK-LABEL: @test4(
 ; CHECK-NEXT:  entry:
@@ -121,12 +120,10 @@ define void @test4(i32 %a, i28* %ptr) {
 ; CHECK-NEXT:[[GEP1:%.*]] = getelementptr i28, i28* [[PTR:%.*]], i32 1
 ; CHECK-NEXT:[[GEP2:%.*]] = getelementptr i28, i28* [[PTR]], i32 2
 ; CHECK-NEXT:[[GEP3:%.*]] = getelementptr i28, i28* [[PTR]], i32 3
-; CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x i28> poison, i28 [[TRUNC]], 
i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = insertelement <4 x i28> [[TMP0]], i28 
[[TRUNC]], i32 1
-; CHECK-NEXT:[[TMP2:%.*]] = insertelement <4 x i28> [[TMP1]], i28 
[[TRUNC]], i32 2
-; CHECK-NEXT:[[TMP3:%.*]] = insertelement <4 x i28> [[TMP2]], i28 
[[TRUNC]], i32 3
-; CHECK-NEXT:[[TMP4:%.*]] = bitcast i28* [[PTR]] to <4 x i28>*
-; CHECK-NEXT:store <4 x i28> [[TMP3]], <4 x i28>* [[TMP4]], align 4
+; CHECK-NEXT:store i28 [[TRUNC]], i28* [[PTR]], align 4
+; CHECK-NEXT:store i28 [[TRUNC]], i28* [[GEP1]], align 4
+; CHECK-NEXT:store i28 [[TRUNC]], i28* [[GEP2]], align 4
+; CHECK-NEXT:store i28 [[TRUNC]], i28* [[GEP3]], align 4
 ; CHECK-NEXT:ret void
 ;
 entry:



___
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] 4f15556 - [LegalizeDAG] Handle NeedInvert when expanding BR_CC

2021-01-16 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-16T14:33:19+01:00
New Revision: 4f155567317d3187bc18be866b3f3b5352f1bfa5

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

LOG: [LegalizeDAG] Handle NeedInvert when expanding BR_CC

This is a follow-up fix to commit 03c8d6a0c4bd0016bdfd1e5.
Seems like we now end up with NeedInvert being set in the result
from LegalizeSetCCCondCode more often than in the past, so we
need to handle NeedInvert when expanding BR_CC.

Not sure how to deal with the "Tmp4.getNode()" case properly,
but current assumption is that that code path isn't impacted
by the changes in 03c8d6a0c4bd0016bdfd1e5 so we can simply move
the old assert into the if-branch and only handle NeedInvert in the
else-branch.

I think that the test case added here, for PowerPC, might have
failed also before commit 03c8d6a0c4bd0016bdfd1e5. But we started
to hit the assert more often downstream when having merged that
commit.

Reviewed By: craig.topper

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

Added: 
llvm/test/CodeGen/PowerPC/legalize-invert-br_cc.ll

Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 2437b07e7d0e..2ef3d9947169 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3966,16 +3966,16 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
 (void)Legalized;
 assert(Legalized && "Can't legalize BR_CC with legal condition!");
 
-assert(!NeedInvert && "Don't know how to invert BR_CC!");
-
 // If we expanded the SETCC by swapping LHS and RHS, create a new BR_CC
 // node.
 if (Tmp4.getNode()) {
+  assert(!NeedInvert && "Don't know how to invert BR_CC!");
+
   Tmp1 = DAG.getNode(ISD::BR_CC, dl, Node->getValueType(0), Tmp1,
  Tmp4, Tmp2, Tmp3, Node->getOperand(4));
 } else {
   Tmp3 = DAG.getConstant(0, dl, Tmp2.getValueType());
-  Tmp4 = DAG.getCondCode(ISD::SETNE);
+  Tmp4 = DAG.getCondCode(NeedInvert ? ISD::SETEQ : ISD::SETNE);
   Tmp1 = DAG.getNode(ISD::BR_CC, dl, Node->getValueType(0), Tmp1, Tmp4,
  Tmp2, Tmp3, Node->getOperand(4));
 }

diff  --git a/llvm/test/CodeGen/PowerPC/legalize-invert-br_cc.ll 
b/llvm/test/CodeGen/PowerPC/legalize-invert-br_cc.ll
new file mode 100644
index ..1e109d0ea4a7
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/legalize-invert-br_cc.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -O1 -mtriple powerpc -mattr=+spe -o - %s | FileCheck %s
+
+; This used to hit an assert
+;
+;   ../lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:3971: bool 
{anonymous}::SelectionDAGLegalize::ExpandNode(llvm::SDNode*): Assertion 
`!NeedInvert && "Don't know how to invert BR_CC!"' failed.
+
+define void @test_fcmpueq_legalize_br_cc_with_invert(float %a) {
+; CHECK-LABEL: test_fcmpueq_legalize_br_cc_with_invert:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lis 4, .LCPI0_0@ha
+; CHECK-NEXT:lwz 4, .LCPI0_0@l(4)
+; CHECK-NEXT:  .LBB0_1: # %l1
+; CHECK-NEXT:#
+; CHECK-NEXT:efscmplt 7, 3, 4
+; CHECK-NEXT:efscmpgt 0, 3, 4
+; CHECK-NEXT:mfcr 5 # cr7
+; CHECK-NEXT:mcrf 7, 0
+; CHECK-NEXT:mfcr 6 # cr7
+; CHECK-NEXT:rlwinm 5, 5, 30, 31, 31
+; CHECK-NEXT:rlwinm 6, 6, 30, 31, 31
+; CHECK-NEXT:or. 5, 6, 5
+; CHECK-NEXT:beq 0, .LBB0_1
+; CHECK-NEXT:  # %bb.2: # %l2
+; CHECK-NEXT:blr
+entry:
+  br label %l1
+l1:
+  %fcmp = fcmp ueq float %a, 0xC6306B344000
+  br i1 %fcmp, label %l1, label %l2
+l2:
+  ret 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] 985b9b7 - [PM] Avoid duplicates in the Used/Preserved/Required sets

2021-01-20 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-20T13:55:18+01:00
New Revision: 985b9b7e421a16e8fcab7f038601a23a25cdfd5d

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

LOG: [PM] Avoid duplicates in the Used/Preserved/Required sets

The pass analysis uses "sets" implemented using a SmallVector type
to keep track of Used, Preserved, Required and RequiredTransitive
passes. When having nested analyses we could end up with duplicates
in those sets, as there was no checks to see if a pass already
existed in the "set" before pushing to the vectors. This idea with
this patch is to avoid such duplicates by avoiding pushing elements
that already is contained when adding elements to those sets.

To align with the above PMDataManager::collectRequiredAndUsedAnalyses
is changed to skip adding both the Required and RequiredTransitive
passes to its result vectors (since RequiredTransitive always is
a subset of Required we ended up with duplicates when traversing
both sets).

Main goal with this is to avoid spending time verifying the same
analysis mulitple times in PMDataManager::verifyPreservedAnalysis
when iterating over the Preserved "set". It is assumed that removing
duplicates from a "set" shouldn't have any other negative impact
(I have not seen any problems so far). If this ends up causing
problems one could do some uniqueness filtering of the vector being
traversed in verifyPreservedAnalysis instead.

Reviewed By: foad

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

Added: 


Modified: 
llvm/include/llvm/PassAnalysisSupport.h
llvm/lib/IR/LegacyPassManager.cpp
llvm/lib/IR/Pass.cpp

Removed: 




diff  --git a/llvm/include/llvm/PassAnalysisSupport.h 
b/llvm/include/llvm/PassAnalysisSupport.h
index 4e28466c4968..4bed3cb55a90 100644
--- a/llvm/include/llvm/PassAnalysisSupport.h
+++ b/llvm/include/llvm/PassAnalysisSupport.h
@@ -17,11 +17,12 @@
 
 #if !defined(LLVM_PASS_H) || defined(LLVM_PASSANALYSISSUPPORT_H)
 #error "Do not include ; include  instead"
-#endif 
+#endif
 
 #ifndef LLVM_PASSANALYSISSUPPORT_H
 #define LLVM_PASSANALYSISSUPPORT_H
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -58,6 +59,11 @@ class AnalysisUsage {
   SmallVector Used;
   bool PreservesAll = false;
 
+  void pushUnique(VectorType &Set, AnalysisID ID) {
+if (!llvm::is_contained(Set, ID))
+  Set.push_back(ID);
+  }
+
 public:
   AnalysisUsage() = default;
 
@@ -80,17 +86,17 @@ class AnalysisUsage {
   ///@{
   /// Add the specified ID to the set of analyses preserved by this pass.
   AnalysisUsage &addPreservedID(const void *ID) {
-Preserved.push_back(ID);
+pushUnique(Preserved, ID);
 return *this;
   }
   AnalysisUsage &addPreservedID(char &ID) {
-Preserved.push_back(&ID);
+pushUnique(Preserved, &ID);
 return *this;
   }
   /// Add the specified Pass class to the set of analyses preserved by this 
pass.
   template
   AnalysisUsage &addPreserved() {
-Preserved.push_back(&PassClass::ID);
+pushUnique(Preserved, &PassClass::ID);
 return *this;
   }
   ///@}
@@ -99,17 +105,17 @@ class AnalysisUsage {
   /// Add the specified ID to the set of analyses used by this pass if they are
   /// available..
   AnalysisUsage &addUsedIfAvailableID(const void *ID) {
-Used.push_back(ID);
+pushUnique(Used, ID);
 return *this;
   }
   AnalysisUsage &addUsedIfAvailableID(char &ID) {
-Used.push_back(&ID);
+pushUnique(Used, &ID);
 return *this;
   }
   /// Add the specified Pass class to the set of analyses used by this pass.
   template
   AnalysisUsage &addUsedIfAvailable() {
-Used.push_back(&PassClass::ID);
+pushUnique(Used, &PassClass::ID);
 return *this;
   }
   ///@}

diff  --git a/llvm/lib/IR/LegacyPassManager.cpp 
b/llvm/lib/IR/LegacyPassManager.cpp
index f35c5048ae68..5575bc469a87 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -1110,12 +1110,6 @@ void PMDataManager::collectRequiredAndUsedAnalyses(
   UP.push_back(AnalysisPass);
 else
   RP_NotAvail.push_back(RequiredID);
-
-  for (const auto &RequiredID : AnUsage->getRequiredTransitiveSet())
-if (Pass *AnalysisPass = findAnalysisPass(RequiredID, true))
-  UP.push_back(AnalysisPass);
-else
-  RP_NotAvail.push_back(RequiredID);
 }
 
 // All Required analyses should be available to the pass as it runs!  Here

diff  --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp
index 0750501a92c4..755ea57c63fd 100644
--- a/llvm/lib/IR/Pass.cpp
+++ b/llvm/lib/IR/Pass.cpp
@@ -259,22 +259,23 @@ void AnalysisUsage::setPreservesCFG() {
 AnalysisUsage &AnalysisUsage::addPreserved(StringRef Arg) {
   const PassInfo *PI = Pass::lookupPassInfo(Arg);
   // If the pass exists, preserve it. Otherw

[llvm-branch-commits] [clang] ea2cfda - [CGExpr] Use getCharWidth() more consistently in CCGExprConstant. NFC

2021-01-22 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-22T21:12:17+01:00
New Revision: ea2cfda386f1a0f0b8cab06a9400bbf4cf7bfbaa

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

LOG: [CGExpr] Use getCharWidth() more consistently in CCGExprConstant. NFC

Most of CGExprConstant.cpp is using the CharUnits abstraction
and is using getCharWidth() (directly of indirectly) when converting
between size of a char and size in bits. This patch is making that
abstraction more consistent by adding CharTy to the CodeGenTypeCache
(honoring getCharWidth() when mapping from char to LLVM IR types,
instead of using Int8Ty directly).

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenTypeCache.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index ca1d3a937fa87..497f9c04c9f80 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -58,14 +58,14 @@ struct ConstantAggregateBuilderUtils {
   }
 
   llvm::Constant *getPadding(CharUnits PadSize) const {
-llvm::Type *Ty = CGM.Int8Ty;
+llvm::Type *Ty = CGM.CharTy;
 if (PadSize > CharUnits::One())
   Ty = llvm::ArrayType::get(Ty, PadSize.getQuantity());
 return llvm::UndefValue::get(Ty);
   }
 
   llvm::Constant *getZeroes(CharUnits ZeroSize) const {
-llvm::Type *Ty = llvm::ArrayType::get(CGM.Int8Ty, ZeroSize.getQuantity());
+llvm::Type *Ty = llvm::ArrayType::get(CGM.CharTy, ZeroSize.getQuantity());
 return llvm::ConstantAggregateZero::get(Ty);
   }
 };
@@ -1069,7 +1069,7 @@ class ConstExprEmitter :
 
   assert(CurSize <= TotalSize && "Union size mismatch!");
   if (unsigned NumPadBytes = TotalSize - CurSize) {
-llvm::Type *Ty = CGM.Int8Ty;
+llvm::Type *Ty = CGM.CharTy;
 if (NumPadBytes > 1)
   Ty = llvm::ArrayType::get(Ty, NumPadBytes);
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 18d633911f555..d93c9690cfb2d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -123,6 +123,8 @@ CodeGenModule::CodeGenModule(ASTContext &C, const 
HeaderSearchOptions &HSO,
 
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
   IntAlignInBytes =
 C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
+  CharTy =
+llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getCharWidth());
   IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
 C.getTargetInfo().getMaxPointerWidth());

diff  --git a/clang/lib/CodeGen/CodeGenTypeCache.h 
b/clang/lib/CodeGen/CodeGenTypeCache.h
index 20a3263c0b1ad..f258234fb4d8f 100644
--- a/clang/lib/CodeGen/CodeGenTypeCache.h
+++ b/clang/lib/CodeGen/CodeGenTypeCache.h
@@ -41,6 +41,9 @@ struct CodeGenTypeCache {
   /// int
   llvm::IntegerType *IntTy;
 
+  /// char
+  llvm::IntegerType *CharTy;
+
   /// intptr_t, size_t, and ptr
diff _t, which we assume are the same size.
   union {
 llvm::IntegerType *IntPtrTy;



___
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] 72f863f - [CodeGen] Use getCharWidth() more consistently in CGRecordLowering. NFC

2021-01-22 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-22T21:12:17+01:00
New Revision: 72f863fd37c3471e7e1b152ac613da00ab6faaba

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

LOG: [CodeGen] Use getCharWidth() more consistently in CGRecordLowering. NFC

When using getByteArrayType the requested size is calculated in
char units, but the type used for the array was hardcoded to the
Int8Ty. This patch is using getCharWIdth a bit more consistently
by using getIntNTy in combination with getCharWidth, instead
of explictly using getInt8Ty.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp 
b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 880342dfed1f..cf8313f92587 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -127,15 +127,20 @@ struct CGRecordLowering {
 
   /// Wraps llvm::Type::getIntNTy with some implicit arguments.
   llvm::Type *getIntNType(uint64_t NumBits) {
+unsigned AlignedBits = llvm::alignTo(NumBits, Context.getCharWidth());
+return llvm::Type::getIntNTy(Types.getLLVMContext(), AlignedBits);
+  }
+  /// Get the LLVM type sized as one character unit.
+  llvm::Type *getCharType() {
 return llvm::Type::getIntNTy(Types.getLLVMContext(),
- (unsigned)llvm::alignTo(NumBits, 8));
+ Context.getCharWidth());
   }
-  /// Gets an llvm type of size NumBytes and alignment 1.
-  llvm::Type *getByteArrayType(CharUnits NumBytes) {
-assert(!NumBytes.isZero() && "Empty byte arrays aren't allowed.");
-llvm::Type *Type = llvm::Type::getInt8Ty(Types.getLLVMContext());
-return NumBytes == CharUnits::One() ? Type :
-(llvm::Type *)llvm::ArrayType::get(Type, NumBytes.getQuantity());
+  /// Gets an llvm type of size NumChars and alignment 1.
+  llvm::Type *getByteArrayType(CharUnits NumChars) {
+assert(!NumChars.isZero() && "Empty byte arrays aren't allowed.");
+llvm::Type *Type = getCharType();
+return NumChars == CharUnits::One() ? Type :
+(llvm::Type *)llvm::ArrayType::get(Type, NumChars.getQuantity());
   }
   /// Gets the storage type for a field decl and handles storage
   /// for itanium bitfields that are smaller than their declared type.



___
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] 675be65 - Require chained analyses in BasicAA and AAResults to be transitive

2021-01-11 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-11T11:50:07+01:00
New Revision: 675be651062476cd0cd4b491b35c275bb03d7b2c

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

LOG: Require chained analyses in BasicAA and AAResults to be transitive

This patch fixes a bug that could result in miscompiles (at least
in an OOT target). The problem could be seen by adding checks that
the DominatorTree used in BasicAliasAnalysis and ValueTracking was
valid (e.g. by adding DT->verify() call before every DT dereference
and then running all tests in test/CodeGen).

Problem was that the LegacyPassManager calculated "last user"
incorrectly for passes such as the DominatorTree when not telling
the pass manager that there was a transitive dependency between
the different analyses. And then it could happen that an incorrect
dominator tree was used when doing alias analysis (which was a pretty
serious bug as the alias analysis result could be invalid).

Fixes: https://bugs.llvm.org/show_bug.cgi?id=48709

Reviewed By: nikic

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

Added: 


Modified: 
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Transforms/Scalar/GVNHoist.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/AliasAnalysis.cpp 
b/llvm/lib/Analysis/AliasAnalysis.cpp
index f5b62ef06a23..fae7a84332fd 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -883,8 +883,8 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
 
 void AAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired();
-  AU.addRequired();
+  AU.addRequiredTransitive();
+  AU.addRequiredTransitive();
 
   // We also need to mark all the alias analysis passes we will potentially
   // probe in runOnFunction as used here to ensure the legacy pass manager

diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 1440906944eb..313a85ccc4de 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1899,9 +1899,9 @@ bool BasicAAWrapperPass::runOnFunction(Function &F) {
 
 void BasicAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired();
-  AU.addRequired();
-  AU.addRequired();
+  AU.addRequiredTransitive();
+  AU.addRequiredTransitive();
+  AU.addRequiredTransitive();
   AU.addUsedIfAvailable();
 }
 

diff  --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp 
b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 68c79d2a113f..76cc8f402c5a 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -165,7 +165,6 @@ class HexagonLoopIdiomRecognizeLegacyPass : public LoopPass 
{
 AU.addRequiredID(LoopSimplifyID);
 AU.addRequiredID(LCSSAID);
 AU.addRequired();
-AU.addPreserved();
 AU.addRequired();
 AU.addRequired();
 AU.addRequired();

diff  --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp 
b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index e2b40942f300..8d0bd5674964 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -547,7 +547,6 @@ class GVNHoistLegacyPass : public FunctionPass {
 AU.addPreserved();
 AU.addPreserved();
 AU.addPreserved();
-AU.addPreserved();
   }
 };
 



___
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] 32c073a - [GlobalISel] Map extractelt to G_EXTRACT_VECTOR_ELT

2021-01-11 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-11T21:53:56+01:00
New Revision: 32c073acb320db3b22ca76b1e21dd688a70b50e8

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

LOG: [GlobalISel] Map extractelt to G_EXTRACT_VECTOR_ELT

Before this patch there was generic mapping from vector_extract
to G_EXTRACT_VECTOR_ELT added in SelectionDAGCompat.td. That
mapping is now replaced by a mapping from extractelt instead.

The reasoning is that vector_extract is marked as deprecated,
so it is assumed that a majority of targets will use extractelt
and not vector_extract (and that the long term solution for all
targets would be to use extractelt).

Targets like AArch64 that still use vector_extract can add an
additional mapping from the deprecated vector_extract as target
specific tablegen definitions. Such a mapping is added for AArch64
in this patch to avoid breaking tests.

When adding the extractelt => G_EXTRACT_VECTOR_ELT mapping we
triggered some new code paths in GlobalISelEmitter, ending up in
an assert when trying to import a pattern containing EXTRACT_SUBREG
for ARM. Therefore this patch also adds a "failedImport" warning
for that situation (instead of hitting the assert).

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

Added: 


Modified: 
llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
llvm/lib/Target/AArch64/AArch64InstrGISel.td
llvm/utils/TableGen/GlobalISelEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td 
b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
index ff4cf3a5d98d..6fb8a6b15dd7 100644
--- a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
+++ b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
@@ -116,7 +116,7 @@ def : GINodeEquiv;
 def : GINodeEquiv;
 def : GINodeEquiv;
 def : GINodeEquiv;
-def : GINodeEquiv;
+def : GINodeEquiv;
 def : GINodeEquiv;
 def : GINodeEquiv;
 def : GINodeEquiv;

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrGISel.td 
b/llvm/lib/Target/AArch64/AArch64InstrGISel.td
index 430155c52302..eadb6847ceb6 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrGISel.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrGISel.td
@@ -164,6 +164,8 @@ def : GINodeEquiv;
 def : GINodeEquiv;
 def : GINodeEquiv;
 
+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), (i64 1,

diff  --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp 
b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 28c7d8b9634a..c10f85abccc4 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -4690,6 +4690,8 @@ Expected 
GlobalISelEmitter::importExplicitUseRenderers(
 
   // EXTRACT_SUBREG needs to use a subregister COPY.
   if (Name == "EXTRACT_SUBREG") {
+if (!Dst->getChild(1)->isLeaf())
+  return failedImport("EXTRACT_SUBREG child #1 is not a leaf");
 DefInit *SubRegInit = dyn_cast(Dst->getChild(1)->getLeafValue());
 if (!SubRegInit)
   return failedImport("EXTRACT_SUBREG child #1 is not a subreg index");



___
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] c4944a6 - [Fixed Point] Add codegen for conversion between fixed-point and floating point.

2021-01-12 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bevin Hansson
Date: 2021-01-12T13:53:01+01:00
New Revision: c4944a6f53f6d1876e76563599f5f149328e7f8f

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

LOG: [Fixed Point] Add codegen for conversion between fixed-point and floating 
point.

The patch adds the required methods to FixedPointBuilder
for converting between fixed-point and floating point,
and uses them from Clang.

This depends on D54749.

Reviewed By: leonardchan

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

Added: 
clang/test/Frontend/fixed_point_conversions_half.c

Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/Frontend/fixed_point_compound.c
clang/test/Frontend/fixed_point_conversions.c
llvm/include/llvm/IR/FixedPointBuilder.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index d6d5ec544c08..6f7e8263fa10 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1212,13 +1212,14 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value 
*Src, QualType SrcType,
   // padding is enabled because overflow into this bit is undefined
   // behavior.
   return Builder.CreateIsNotNull(Src, "tobool");
-if (DstType->isFixedPointType() || DstType->isIntegerType())
+if (DstType->isFixedPointType() || DstType->isIntegerType() ||
+DstType->isRealFloatingType())
   return EmitFixedPointConversion(Src, SrcType, DstType, Loc);
 
 llvm_unreachable(
 "Unhandled scalar conversion from a fixed point type to another 
type.");
   } else if (DstType->isFixedPointType()) {
-if (SrcType->isIntegerType())
+if (SrcType->isIntegerType() || SrcType->isRealFloatingType())
   // This also includes converting booleans and enums to fixed point types.
   return EmitFixedPointConversion(Src, SrcType, DstType, Loc);
 
@@ -1434,19 +1435,29 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value 
*Src, QualType SrcType,
 Value *ScalarExprEmitter::EmitFixedPointConversion(Value *Src, QualType SrcTy,
QualType DstTy,
SourceLocation Loc) {
-  auto SrcFPSema = CGF.getContext().getFixedPointSemantics(SrcTy);
-  auto DstFPSema = CGF.getContext().getFixedPointSemantics(DstTy);
   llvm::FixedPointBuilder FPBuilder(Builder);
   llvm::Value *Result;
-  if (DstTy->isIntegerType())
-Result = FPBuilder.CreateFixedToInteger(Src, SrcFPSema,
-DstFPSema.getWidth(),
-DstFPSema.isSigned());
-  else if (SrcTy->isIntegerType())
-Result =  FPBuilder.CreateIntegerToFixed(Src, SrcFPSema.isSigned(),
- DstFPSema);
-  else
-Result = FPBuilder.CreateFixedToFixed(Src, SrcFPSema, DstFPSema);
+  if (SrcTy->isRealFloatingType())
+Result = FPBuilder.CreateFloatingToFixed(Src,
+CGF.getContext().getFixedPointSemantics(DstTy));
+  else if (DstTy->isRealFloatingType())
+Result = FPBuilder.CreateFixedToFloating(Src,
+CGF.getContext().getFixedPointSemantics(SrcTy),
+ConvertType(DstTy));
+  else {
+auto SrcFPSema = CGF.getContext().getFixedPointSemantics(SrcTy);
+auto DstFPSema = CGF.getContext().getFixedPointSemantics(DstTy);
+
+if (DstTy->isIntegerType())
+  Result = FPBuilder.CreateFixedToInteger(Src, SrcFPSema,
+  DstFPSema.getWidth(),
+  DstFPSema.isSigned());
+else if (SrcTy->isIntegerType())
+  Result =  FPBuilder.CreateIntegerToFixed(Src, SrcFPSema.isSigned(),
+   DstFPSema);
+else
+  Result = FPBuilder.CreateFixedToFixed(Src, SrcFPSema, DstFPSema);
+  }
   return Result;
 }
 

diff  --git a/clang/test/Frontend/fixed_point_compound.c 
b/clang/test/Frontend/fixed_point_compound.c
index 897ba2e22636..5dcc7fba0da7 100644
--- a/clang/test/Frontend/fixed_point_compound.c
+++ b/clang/test/Frontend/fixed_point_compound.c
@@ -16,6 +16,8 @@ int i;
 unsigned int u;
 signed char c;
 
+float fl;
+
 
 // CHECK-LABEL: @add_shfa(
 // CHECK-NEXT:  entry:
@@ -358,6 +360,66 @@ void add_sshsuf() {
   sshf += suf;
 }
 
+// CHECK-LABEL: @add_afl(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* @fl, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* @a, align 4
+// CHECK-NEXT:[[TMP2:%.*]] = sitofp i32 [[TMP1]] to float
+// CHECK-NEXT:[[TMP3:%.*]] = fmul float [[TMP2]], 0x3F00
+// CHECK-NEXT:[[ADD:%.*]] = fadd float [[TMP3]], [[TMP0]]
+// CHECK-NEXT:[[TMP4:%.*]] = fmul float [[ADD]], 3.276800e+04
+// CHECK-NEXT:[[TMP5:%.

[llvm-branch-commits] [llvm] 07605ea - [X86] Improved lowering for saturating float to int.

2021-01-12 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bevin Hansson
Date: 2021-01-12T15:44:41+01:00
New Revision: 07605ea1f3c94e0a23450f5c9ab3902862d7ff03

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

LOG: [X86] Improved lowering for saturating float to int.

Adapted from D54696 by @nikic.

This patch improves lowering of saturating float to
int conversions, FP_TO_[SU]INT_SAT, for X86.

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/fptosi-sat-scalar.ll
llvm/test/CodeGen/X86/fptoui-sat-scalar.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f28e28689806..65b784f31842 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -284,6 +284,19 @@ X86TargetLowering::X86TargetLowering(const 
X86TargetMachine &TM,
 }
   }
 
+  if (Subtarget.hasSSE2()) {
+// Custom lowering for saturating float to int conversions.
+// We handle promotion to larger result types manually.
+for (MVT VT : { MVT::i8, MVT::i16, MVT::i32 }) {
+  setOperationAction(ISD::FP_TO_UINT_SAT, VT, Custom);
+  setOperationAction(ISD::FP_TO_SINT_SAT, VT, Custom);
+}
+if (Subtarget.is64Bit()) {
+  setOperationAction(ISD::FP_TO_UINT_SAT, MVT::i64, Custom);
+  setOperationAction(ISD::FP_TO_SINT_SAT, MVT::i64, Custom);
+}
+  }
+
   // Handle address space casts between mixed sized pointers.
   setOperationAction(ISD::ADDRSPACECAST, MVT::i32, Custom);
   setOperationAction(ISD::ADDRSPACECAST, MVT::i64, Custom);
@@ -21428,6 +21441,155 @@ SDValue X86TargetLowering::LRINT_LLRINTHelper(SDNode 
*N,
   return DAG.getLoad(DstVT, DL, Chain, StackPtr, MPI);
 }
 
+SDValue
+X86TargetLowering::LowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG) const {
+  // This is based on the TargetLowering::expandFP_TO_INT_SAT implementation,
+  // but making use of X86 specifics to produce better instruction sequences.
+  SDNode *Node = Op.getNode();
+  bool IsSigned = Node->getOpcode() == ISD::FP_TO_SINT_SAT;
+  unsigned FpToIntOpcode = IsSigned ? ISD::FP_TO_SINT : ISD::FP_TO_UINT;
+  SDLoc dl(SDValue(Node, 0));
+  SDValue Src = Node->getOperand(0);
+
+  // There are three types involved here: SrcVT is the source floating point
+  // type, DstVT is the type of the result, and TmpVT is the result of the
+  // intermediate FP_TO_*INT operation we'll use (which may be a promotion of
+  // DstVT).
+  EVT SrcVT = Src.getValueType();
+  EVT DstVT = Node->getValueType(0);
+  EVT TmpVT = DstVT;
+
+  // This code is only for floats and doubles. Fall back to generic code for
+  // anything else.
+  if (!isScalarFPTypeInSSEReg(SrcVT))
+return SDValue();
+
+  unsigned SatWidth = Node->getConstantOperandVal(1);
+  unsigned DstWidth = DstVT.getScalarSizeInBits();
+  unsigned TmpWidth = TmpVT.getScalarSizeInBits();
+  assert(SatWidth <= DstWidth && SatWidth <= TmpWidth &&
+ "Expected saturation width smaller than result width");
+
+  // Promote result of FP_TO_*INT to at least 32 bits.
+  if (TmpWidth < 32) {
+TmpVT = MVT::i32;
+TmpWidth = 32;
+  }
+
+  // Promote conversions to unsigned 32-bit to 64-bit, because it will allow
+  // us to use a native signed conversion instead.
+  if (SatWidth == 32 && !IsSigned && Subtarget.is64Bit()) {
+TmpVT = MVT::i64;
+TmpWidth = 64;
+  }
+
+  // If the saturation width is smaller than the size of the temporary result,
+  // we can always use signed conversion, which is native.
+  if (SatWidth < TmpWidth)
+FpToIntOpcode = ISD::FP_TO_SINT;
+
+  // Determine minimum and maximum integer values and their corresponding
+  // floating-point values.
+  APInt MinInt, MaxInt;
+  if (IsSigned) {
+MinInt = APInt::getSignedMinValue(SatWidth).sextOrSelf(DstWidth);
+MaxInt = APInt::getSignedMaxValue(SatWidth).sextOrSelf(DstWidth);
+  } else {
+MinInt = APInt::getMinValue(SatWidth).zextOrSelf(DstWidth);
+MaxInt = APInt::getMaxValue(SatWidth).zextOrSelf(DstWidth);
+  }
+
+  APFloat MinFloat(DAG.EVTToAPFloatSemantics(SrcVT));
+  APFloat MaxFloat(DAG.EVTToAPFloatSemantics(SrcVT));
+
+  APFloat::opStatus MinStatus = MinFloat.convertFromAPInt(
+MinInt, IsSigned, APFloat::rmTowardZero);
+  APFloat::opStatus MaxStatus = MaxFloat.convertFromAPInt(
+MaxInt, IsSigned, APFloat::rmTowardZero);
+  bool AreExactFloatBounds = !(MinStatus & APFloat::opStatus::opInexact)
+  && !(MaxStatus & APFloat::opStatus::opInexact);
+
+  SDValue MinFloatNode = DAG.getConstantFP(MinFloat, dl, SrcVT);
+  SDValue MaxFloatNode = DAG.getConstantFP(MaxFloat, dl, SrcVT);
+
+  // If the integer bounds are exactly repr

[llvm-branch-commits] [llvm] dd07d60 - [SLP] Add test case showing a bug when dealing with padded types

2021-01-12 Thread Bjorn Pettersson via llvm-branch-commits

Author: Bjorn Pettersson
Date: 2021-01-12T16:35:33+01:00
New Revision: dd07d60ec33969ae4f1e37500bb852563e142dfb

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

LOG: [SLP] Add test case showing a bug when dealing with padded types

We shouldn't vectorize stores of non-packed types (i.e. types that
has padding between consecutive variables in a scalar layout,
but being packed in a vector layout).

The problem was detected as a miscompile in a downstream test case.

This is a pre-commit of a test case for the fix in D94446.

Added: 


Modified: 
llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll

Removed: 




diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
index b9fd032b5662..93a97c3c2405 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll
@@ -15,8 +15,8 @@ define void @test1(x86_mmx %a, x86_mmx %b, i64* %ptr) {
 ; CHECK-NEXT:[[A_AND:%.*]] = and i64 [[A_CAST]], 42
 ; CHECK-NEXT:[[B_AND:%.*]] = and i64 [[B_CAST]], 42
 ; CHECK-NEXT:[[GEP:%.*]] = getelementptr i64, i64* [[PTR:%.*]], i32 1
-; CHECK-NEXT:store i64 [[A_AND]], i64* [[PTR]]
-; CHECK-NEXT:store i64 [[B_AND]], i64* [[GEP]]
+; CHECK-NEXT:store i64 [[A_AND]], i64* [[PTR]], align 8
+; CHECK-NEXT:store i64 [[B_AND]], i64* [[GEP]], align 8
 ; CHECK-NEXT:ret void
 ;
 entry:
@@ -110,3 +110,33 @@ bb1:  ; preds 
= %entry
 }
 
 declare void @f(i64, i64)
+
+define void @test4(i32 %a, i28* %ptr) {
+; Check that we do not vectorize types that are padded to a bigger ones.
+; FIXME: This is not correct! See D94446.
+;
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TRUNC:%.*]] = trunc i32 [[A:%.*]] to i28
+; CHECK-NEXT:[[GEP1:%.*]] = getelementptr i28, i28* [[PTR:%.*]], i32 1
+; CHECK-NEXT:[[GEP2:%.*]] = getelementptr i28, i28* [[PTR]], i32 2
+; CHECK-NEXT:[[GEP3:%.*]] = getelementptr i28, i28* [[PTR]], i32 3
+; CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x i28> poison, i28 [[TRUNC]], 
i32 0
+; CHECK-NEXT:[[TMP1:%.*]] = insertelement <4 x i28> [[TMP0]], i28 
[[TRUNC]], i32 1
+; CHECK-NEXT:[[TMP2:%.*]] = insertelement <4 x i28> [[TMP1]], i28 
[[TRUNC]], i32 2
+; CHECK-NEXT:[[TMP3:%.*]] = insertelement <4 x i28> [[TMP2]], i28 
[[TRUNC]], i32 3
+; CHECK-NEXT:[[TMP4:%.*]] = bitcast i28* [[PTR]] to <4 x i28>*
+; CHECK-NEXT:store <4 x i28> [[TMP3]], <4 x i28>* [[TMP4]], align 4
+; CHECK-NEXT:ret void
+;
+entry:
+  %trunc = trunc i32 %a to i28
+  %gep1 = getelementptr i28, i28* %ptr, i32 1
+  %gep2 = getelementptr i28, i28* %ptr, i32 2
+  %gep3 = getelementptr i28, i28* %ptr, i32 3
+  store i28 %trunc, i28* %ptr
+  store i28 %trunc, i28* %gep1
+  store i28 %trunc, i28* %gep2
+  store i28 %trunc, i28* %gep3
+  ret void
+}



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