Skip to content

Commit e02697b

Browse files
arsenmgithub-actions[bot]
authored andcommitted
Automerge: SeparateConstOffsetFromGEP: Avoid looking at constant uses (#134685)
We could be more aggressive and inspect uses of global variables, if the use context instruction is in the same function.
2 parents 3bef922 + 1a99284 commit e02697b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,11 @@ bool SeparateConstOffsetFromGEP::isLegalToSwapOperand(
13531353
}
13541354

13551355
bool SeparateConstOffsetFromGEP::hasMoreThanOneUseInLoop(Value *V, Loop *L) {
1356+
// TODO: Could look at uses of globals, but we need to make sure we are
1357+
// looking at the correct function.
1358+
if (isa<Constant>(V))
1359+
return false;
1360+
13561361
int UsesInLoop = 0;
13571362
for (User *U : V->users()) {
13581363
if (Instruction *User = dyn_cast<Instruction>(U))

Diff for: llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/lower-gep.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ define amdgpu_kernel void @multi_use_in_loop_global_base_address(ptr addrspace(1
425425
; CHECK-NEXT: [[TMP25]] = add nuw nsw i32 [[TMP13]], 1
426426
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[TMP13]] to i64
427427
; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[TMP0]], 2
428-
; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr addrspace(1) @extern_array_1, i64 [[TMP1]]
429-
; CHECK-NEXT: [[UGLYGEP2:%.*]] = getelementptr i8, ptr addrspace(1) [[UGLYGEP]], i64 4
428+
; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr addrspace(1) @extern_array_1, i64 4
429+
; CHECK-NEXT: [[UGLYGEP2:%.*]] = getelementptr i8, ptr addrspace(1) [[UGLYGEP]], i64 [[TMP1]]
430430
; CHECK-NEXT: [[TMP28:%.*]] = load i32, ptr addrspace(1) [[UGLYGEP2]], align 4
431431
; CHECK-NEXT: [[TMP29:%.*]] = add i32 [[TMP24]], [[TMP12]]
432432
; CHECK-NEXT: [[TMP30]] = add i32 [[TMP29]], [[TMP28]]

0 commit comments

Comments
 (0)