Skip to content

Commit e2e58ee

Browse files
committed
Added nonbyte test. Removed interface to isValidAtomicTy.
1 parent 67e0560 commit e2e58ee

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

llvm/include/llvm/IR/Instructions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,6 @@ class LoadInst : public UnaryInstruction {
250250
!isVolatile();
251251
}
252252

253-
/// Returns false if this type would be invalid in the
254-
/// creation of a load atomic instruction.
255-
static bool isValidAtomicTy(Type *Ty, const DataLayout *DL = nullptr,
256-
AtomicOrdering AO = AtomicOrdering::NotAtomic);
257-
258253
Value *getPointerOperand() { return getOperand(0); }
259254
const Value *getPointerOperand() const { return getOperand(0); }
260255
static unsigned getPointerOperandIndex() { return 0U; }

llvm/lib/IR/Instructions.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,20 +1247,6 @@ void LoadInst::AssertOK() {
12471247
"Ptr must have pointer type.");
12481248
}
12491249

1250-
bool LoadInst::isValidAtomicTy(Type *Ty, const DataLayout *DL,
1251-
AtomicOrdering AO) {
1252-
// TODO: Share methods with IR/Verifier.
1253-
if (!Ty->isIntOrPtrTy() && !Ty->isFloatingPointTy())
1254-
return false;
1255-
if (AO == AtomicOrdering::Release || AO == AtomicOrdering::AcquireRelease)
1256-
return false;
1257-
if (DL) {
1258-
unsigned Size = DL->getTypeSizeInBits(Ty);
1259-
return Size >= 8 && !(Size & (Size - 1));
1260-
}
1261-
return true;
1262-
}
1263-
12641250
static Align computeLoadStoreDefaultAlign(Type *Ty, InsertPosition Pos) {
12651251
assert(Pos.isValid() &&
12661252
"Insertion position cannot be null when alignment not provided!");

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,9 +2854,9 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
28542854
bool visitLoadInst(LoadInst &LI) {
28552855
LLVM_DEBUG(dbgs() << " original: " << LI << "\n");
28562856

2857-
// Load atomic vector would be generated, which is illegal.
2857+
// A load atomic vector would be generated, which is illegal.
28582858
// TODO: Generate a generic bitcast in machine codegen instead.
2859-
if (LI.isAtomic() && !LoadInst::isValidAtomicTy(NewAI.getAllocatedType()))
2859+
if (LI.isAtomic() && NewAI.getAllocatedType()->isVectorTy())
28602860
return false;
28612861

28622862
Value *OldOp = LI.getOperand(0);
@@ -2881,7 +2881,6 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
28812881
(canConvertValue(DL, NewAllocaTy, TargetTy) ||
28822882
(IsLoadPastEnd && NewAllocaTy->isIntegerTy() &&
28832883
TargetTy->isIntegerTy() && !LI.isVolatile()))) {
2884-
28852884
Value *NewPtr =
28862885
getPtrToNewAI(LI.getPointerAddressSpace(), LI.isVolatile());
28872886
LoadInst *NewLI = IRB.CreateAlignedLoad(NewAI.getAllocatedType(), NewPtr,

llvm/test/Transforms/SROA/atomic-vector.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,23 @@ define i32 @atomic_2vector_int() {
6868
%ret = load atomic volatile i32, ptr %indirect acquire, align 4
6969
ret i32 %ret
7070
}
71+
72+
define i32 @atomic_2vector_nonbyte_illegal_int() {
73+
; CHECK-LABEL: define i32 @atomic_2vector_nonbyte_illegal_int() {
74+
; CHECK-NEXT: [[SRC_SROA_1:%.*]] = alloca i17, align 4
75+
; CHECK-NEXT: [[VAL_SROA_0:%.*]] = alloca i32, align 8
76+
; CHECK-NEXT: [[VAL_SROA_2:%.*]] = alloca i17, align 4
77+
; CHECK-NEXT: store i32 undef, ptr [[VAL_SROA_0]], align 8
78+
; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[VAL_SROA_2]], ptr align 4 [[SRC_SROA_1]], i64 4, i1 false)
79+
; CHECK-NEXT: [[VAL_SROA_0_0_VAL_SROA_0_0_RET:%.*]] = load atomic volatile i32, ptr [[VAL_SROA_0]] acquire, align 4
80+
; CHECK-NEXT: ret i32 [[VAL_SROA_0_0_VAL_SROA_0_0_RET]]
81+
;
82+
%src = alloca <2 x i17>
83+
%val = alloca <2 x i17>
84+
%direct = alloca ptr
85+
call void @llvm.memcpy.p0.p0.i64(ptr %val, ptr %src, i64 8, i1 false)
86+
store ptr %val, ptr %direct
87+
%indirect = load ptr, ptr %direct
88+
%ret = load atomic volatile i32, ptr %indirect acquire, align 4
89+
ret i32 %ret
90+
}

0 commit comments

Comments
 (0)