Skip to content

[ConstantFolding] Infer getelementptr nuw flag #119214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/test/CodeGen/RISCV/riscv-inline-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ extern int var, arr[2][2];
struct Pair { int a, b; } pair;

// CHECK-LABEL: test_s(
// CHECK: call void asm sideeffect "// $0 $1 $2", "s,s,s"(ptr nonnull @var, ptr nonnull getelementptr inbounds (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
// CHECK: call void asm sideeffect "// $0 $1 $2", "s,s,s"(ptr nonnull @var, ptr nonnull getelementptr inbounds nuw (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
// CHECK: call void asm sideeffect "// $0", "s"(ptr nonnull getelementptr inbounds nuw (i8, ptr @pair, {{.*}}))
// CHECK: call void asm sideeffect "// $0 $1 $2", "S,S,S"(ptr nonnull @var, ptr nonnull getelementptr inbounds (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
// CHECK: call void asm sideeffect "// $0 $1 $2", "S,S,S"(ptr nonnull @var, ptr nonnull getelementptr inbounds nuw (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
void test_s(void) {
asm("// %0 %1 %2" :: "s"(&var), "s"(&arr[1][1]), "s"(test_s));
asm("// %0" :: "s"(&pair.b));
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenCXX/auto-var-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ TEST_UNINIT(base, base);
// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_base_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
// ZERO-LABEL: @test_base_uninit()
// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation [[AUTO_INIT]]
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV4base, i64 16), {{.*}}, align 8
// ZERO-O1: store ptr getelementptr inbounds nuw inrange(-16, 16) (i8, ptr @_ZTV4base, i64 16), {{.*}}, align 8
// ZERO-O1-NOT: !annotation

TEST_BRACES(base, base);
Expand All @@ -1359,7 +1359,7 @@ TEST_UNINIT(derived, derived);
// ZERO-LABEL: @test_derived_uninit()
// ZERO-O0: call void @llvm.memset{{.*}}, i8 0, {{.+}}), !annotation [[AUTO_INIT]]
// ZERO-O1: store i64 0, {{.*}} align 8, !annotation [[AUTO_INIT]]
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV7derived, i64 16), {{.*}} align 8
// ZERO-O1: store ptr getelementptr inbounds nuw inrange(-16, 16) (i8, ptr @_ZTV7derived, i64 16), {{.*}} align 8

TEST_BRACES(derived, derived);
// CHECK-LABEL: @test_derived_braces()
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
}

// Try to infer inbounds for GEPs of globals.
// TODO(gep_nowrap): Also infer nuw flag.
if (!NW.isInBounds() && Offset.isNonNegative()) {
bool CanBeNull, CanBeFreed;
uint64_t DerefBytes =
Expand All @@ -961,6 +960,10 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
NW |= GEPNoWrapFlags::inBounds();
}

// nusw + nneg -> nuw
if (NW.hasNoUnsignedSignedWrap() && Offset.isNonNegative())
NW |= GEPNoWrapFlags::noUnsignedWrap();

// Otherwise canonicalize this to a single ptradd.
LLVMContext &Ctx = Ptr->getContext();
return ConstantExpr::getGetElementPtr(Type::getInt8Ty(Ctx), Ptr,
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Other/constant-fold-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@

; PLAIN: @Y = global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 1), i64 1)
; PLAIN: @Z = global ptr getelementptr inbounds (i32, ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 0), i64 1)
; OPT: @Y = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 48)
; OPT: @Z = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 12)
; TO: @Y = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 48)
; TO: @Z = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 12)
; OPT: @Y = local_unnamed_addr global ptr getelementptr inbounds nuw (i8, ptr @ext, i64 48)
; OPT: @Z = local_unnamed_addr global ptr getelementptr inbounds nuw (i8, ptr @ext, i64 12)
; TO: @Y = local_unnamed_addr global ptr getelementptr inbounds nuw (i8, ptr @ext, i64 48)
; TO: @Z = local_unnamed_addr global ptr getelementptr inbounds nuw (i8, ptr @ext, i64 12)

@ext = external global [3 x { i32, i32 }]
@Y = global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 1), i64 1)
Expand Down Expand Up @@ -433,10 +433,10 @@ define ptr @fO() nounwind {
; PLAIN: ret ptr %t
; PLAIN: }
; OPT: define ptr @fZ() local_unnamed_addr #0 {
; OPT: ret ptr getelementptr inbounds (i8, ptr @ext, i64 12)
; OPT: ret ptr getelementptr inbounds nuw (i8, ptr @ext, i64 12)
; OPT: }
; TO: define ptr @fZ() local_unnamed_addr #0 {
; TO: ret ptr getelementptr inbounds (i8, ptr @ext, i64 12)
; TO: ret ptr getelementptr inbounds nuw (i8, ptr @ext, i64 12)
; TO: }
; SCEV: Classifying expressions for: @fZ
; SCEV: %t = bitcast ptr getelementptr inbounds (i32, ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 0), i64 1) to ptr
Expand All @@ -457,14 +457,14 @@ define ptr @different_addrspace() nounwind noinline {
%p = getelementptr inbounds i8, ptr addrspacecast (ptr addrspace(12) @p12 to ptr),
i32 2
ret ptr %p
; OPT: ret ptr getelementptr inbounds (i8, ptr addrspacecast (ptr addrspace(12) @p12 to ptr), i64 2)
; OPT: ret ptr getelementptr inbounds nuw (i8, ptr addrspacecast (ptr addrspace(12) @p12 to ptr), i64 2)
}

define ptr @same_addrspace() nounwind noinline {
; OPT: same_addrspace
%p = getelementptr inbounds i8, ptr @p0, i32 2
ret ptr %p
; OPT: ret ptr getelementptr inbounds (i8, ptr @p0, i64 2)
; OPT: ret ptr getelementptr inbounds nuw (i8, ptr @p0, i64 2)
}

@gv1 = internal global i32 1
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Other/optimize-inrange-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define void @foo(ptr %p) {
;
; CHECK-LABEL: define void @foo(
; CHECK-SAME: ptr nocapture writeonly initializes((0, 8)) [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: store ptr getelementptr inbounds inrange(-24, 0) (i8, ptr @vtable, i64 24), ptr [[P]], align 8
; CHECK-NEXT: store ptr getelementptr inbounds nuw inrange(-24, 0) (i8, ptr @vtable, i64 24), ptr [[P]], align 8
; CHECK-NEXT: ret void
;
store ptr getelementptr inrange(-24, 0) ({ [3 x ptr], [3 x ptr] }, ptr @vtable, i32 0, i32 0, i32 3), ptr %p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ define internal i64 @zoo(i1 %flag) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[PLUS:%.*]], label [[MINUS:%.*]]
; CHECK: plus:
; CHECK-NEXT: [[TMP0:%.*]] = call i64 @func2.specialized.2(ptr getelementptr inbounds (i8, ptr @Global, i64 8))
; CHECK-NEXT: [[TMP0:%.*]] = call i64 @func2.specialized.2(ptr getelementptr inbounds nuw (i8, ptr @Global, i64 8))
; CHECK-NEXT: br label [[MERGE:%.*]]
; CHECK: minus:
; CHECK-NEXT: [[TMP1:%.*]] = call i64 @func2.specialized.1(ptr getelementptr inbounds (i8, ptr @Global, i64 16))
; CHECK-NEXT: [[TMP1:%.*]] = call i64 @func2.specialized.1(ptr getelementptr inbounds nuw (i8, ptr @Global, i64 16))
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ ptrtoint (ptr getelementptr inbounds (i8, ptr @Global, i64 8) to i64), [[PLUS]] ], [ ptrtoint (ptr getelementptr inbounds (i8, ptr @Global, i64 16) to i64), [[MINUS]] ]
; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ ptrtoint (ptr getelementptr inbounds nuw (i8, ptr @Global, i64 8) to i64), [[PLUS]] ], [ ptrtoint (ptr getelementptr inbounds nuw (i8, ptr @Global, i64 16) to i64), [[MINUS]] ]
; CHECK-NEXT: ret i64 [[TMP2]]
;
entry:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/GVN/PRE/load-pre-licm.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target triple = "i386-apple-darwin11.0.0"
define void @Bubble() nounwind noinline {
; CHECK-LABEL: @Bubble(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP7_PRE:%.*]] = load i32, ptr getelementptr inbounds (i8, ptr @sortlist, i32 4), align 4
; CHECK-NEXT: [[TMP7_PRE:%.*]] = load i32, ptr getelementptr inbounds nuw (i8, ptr @sortlist, i32 4), align 4
; CHECK-NEXT: br label [[WHILE_BODY5:%.*]]
; CHECK: while.body5:
; CHECK-NEXT: [[TMP7:%.*]] = phi i32 [ [[TMP7_PRE]], [[ENTRY:%.*]] ], [ [[TMP71:%.*]], [[IF_END:%.*]] ]
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/GVN/PRE/phi-translate-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ define void @test2(i64 %i) {
; CHECK: if.then:
; CHECK-NEXT: [[CALL:%.*]] = tail call i64 (...) @goo()
; CHECK-NEXT: store i64 [[CALL]], ptr @g2, align 8
; CHECK-NEXT: [[T2_PRE:%.*]] = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 24), align 8
; CHECK-NEXT: [[T3_PRE:%.*]] = load i64, ptr getelementptr inbounds (i8, ptr @b, i64 24), align 8
; CHECK-NEXT: [[T2_PRE:%.*]] = load i64, ptr getelementptr inbounds nuw (i8, ptr @a, i64 24), align 8
; CHECK-NEXT: [[T3_PRE:%.*]] = load i64, ptr getelementptr inbounds nuw (i8, ptr @b, i64 24), align 8
; CHECK-NEXT: [[DOTPRE:%.*]] = mul nsw i64 [[T3_PRE]], [[T2_PRE]]
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
Expand Down Expand Up @@ -272,7 +272,7 @@ define void @test6(ptr %ptr, i1 %arg) {
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[TMP2]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ [[TMP1]], [[WHILE]] ]
; CHECK-NEXT: br i1 %arg, label [[WHILE_END:%.*]], label [[WHILE]]
; CHECK-NEXT: br i1 [[ARG:%.*]], label [[WHILE_END:%.*]], label [[WHILE]]
; CHECK: while.end:
; CHECK-NEXT: ret void
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define void @foo() {
; CHECK-NEXT: bb:
; CHECK-NEXT: br label [[BB3:%.*]]
; CHECK: bb3:
; CHECK-NEXT: [[TMP6:%.*]] = load i8, ptr getelementptr inbounds (i8, ptr @global, i64 1), align 1
; CHECK-NEXT: [[TMP6:%.*]] = load i8, ptr getelementptr inbounds nuw (i8, ptr @global, i64 1), align 1
; CHECK-NEXT: br i1 false, label [[BB7:%.*]], label [[BB11:%.*]]
; CHECK: bb7:
; CHECK-NEXT: [[TMP8:%.*]] = zext i8 [[TMP6]] to i64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ define void @uitofp_fptoui_range_with_negative() {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds (i8, ptr @array, i64 400), align 4
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds nuw (i8, ptr @array, i64 400), align 4
; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[CLEANUP:%.*]]
; CHECK: cleanup:
; CHECK-NEXT: ret void
Expand Down Expand Up @@ -418,7 +418,7 @@ define void @uitofp_fptosi_range_with_negative () {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds (i8, ptr @array, i64 400), align 4
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds nuw (i8, ptr @array, i64 400), align 4
; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[CLEANUP:%.*]]
; CHECK: cleanup:
; CHECK-NEXT: ret void
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstCombine/addrspacecast.ll
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ define i32 @memcpy_addrspacecast() nounwind {
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP_BODY]] ]
; CHECK-NEXT: [[SUM:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[SUM_INC:%.*]], [[LOOP_BODY]] ]
; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[I]] to i16
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i8, ptr addrspace(2) getelementptr inbounds (i8, ptr addrspace(2) @const_array, i16 4), i16 [[TMP0]]
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i8, ptr addrspace(2) getelementptr inbounds nuw (i8, ptr addrspace(2) @const_array, i16 4), i16 [[TMP0]]
; CHECK-NEXT: [[LOAD:%.*]] = load i8, ptr addrspace(2) [[PTR]], align 1
; CHECK-NEXT: [[EXT:%.*]] = zext i8 [[LOAD]] to i32
; CHECK-NEXT: [[SUM_INC]] = add i32 [[SUM]], [[EXT]]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstCombine/align-addr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ define <16 x i8> @test1_as1(<2 x i64> %x) {

define <16 x i8> @test1_as1_gep(<2 x i64> %x) {
; CHECK-LABEL: @test1_as1_gep(
; CHECK-NEXT: [[TMP:%.*]] = load <16 x i8>, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) @GLOBAL_as1_gep, i32 16), align 1
; CHECK-NEXT: [[TMP:%.*]] = load <16 x i8>, ptr addrspace(1) getelementptr inbounds nuw (i8, ptr addrspace(1) @GLOBAL_as1_gep, i32 16), align 1
; CHECK-NEXT: ret <16 x i8> [[TMP]]
;
%tmp = load <16 x i8>, ptr addrspace(1) getelementptr ([8 x i32], ptr addrspace(1) @GLOBAL_as1_gep, i16 0, i16 4), align 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ define <2 x i8> @vectorized_add(<2 x i1> %c, <2 x i8> %arg) {
define i64 @pr64669(i64 %a) {
; CHECK-LABEL: define i64 @pr64669
; CHECK-SAME: (i64 [[A:%.*]]) {
; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq ptr getelementptr inbounds (i8, ptr @b, i64 100), @c
; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq ptr getelementptr inbounds nuw (i8, ptr @b, i64 100), @c
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[A]], 1
; CHECK-NEXT: [[ADD:%.*]] = select i1 [[CMP_NOT]], i64 0, i64 [[TMP1]]
; CHECK-NEXT: ret i64 [[ADD]]
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/Transforms/InstCombine/canonicalize-gep-constglob.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define ptr @x12(i64 %x) {
; CHECK-SAME: i64 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP_IDX:%.*]] = mul nsw i64 [[X]], 400
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr getelementptr inbounds (i8, ptr @glob, i64 84), i64 [[GEP_IDX]]
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr getelementptr inbounds nuw (i8, ptr @glob, i64 84), i64 [[GEP_IDX]]
; CHECK-NEXT: ret ptr [[GEP]]
;
entry:
Expand All @@ -22,7 +22,7 @@ define ptr @x1y(i64 %x, i64 %y) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP_IDX:%.*]] = mul nsw i64 [[X]], 400
; CHECK-NEXT: [[GEP_IDX1:%.*]] = shl nsw i64 [[Y]], 2
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr getelementptr inbounds (i8, ptr @glob, i64 116), i64 [[GEP_IDX]]
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr getelementptr inbounds nuw (i8, ptr @glob, i64 116), i64 [[GEP_IDX]]
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[TMP0]], i64 [[GEP_IDX1]]
; CHECK-NEXT: ret ptr [[GEP]]
;
Expand All @@ -35,7 +35,7 @@ define ptr @xzy(i64 %x, i64 %y, i64 %z) {
; CHECK-LABEL: define ptr @xzy(
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], i64 [[Z:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [10 x [10 x [10 x i32]]], ptr getelementptr inbounds (i8, ptr @glob, i64 40), i64 0, i64 [[X]], i64 [[Z]], i64 [[Y]]
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [10 x [10 x [10 x i32]]], ptr getelementptr inbounds nuw (i8, ptr @glob, i64 40), i64 0, i64 [[X]], i64 [[Z]], i64 [[Y]]
; CHECK-NEXT: ret ptr [[GEP]]
;
entry:
Expand All @@ -47,7 +47,7 @@ define ptr @zerox(i64 %x) {
; CHECK-LABEL: define ptr @zerox(
; CHECK-SAME: i64 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [10 x i32], ptr getelementptr inbounds (i8, ptr @glob, i64 32), i64 0, i64 [[X]]
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [10 x i32], ptr getelementptr inbounds nuw (i8, ptr @glob, i64 32), i64 0, i64 [[X]]
; CHECK-NEXT: ret ptr [[GEP]]
;
entry:
Expand All @@ -60,9 +60,9 @@ define i32 @twoloads(i64 %x) {
; CHECK-SAME: i64 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP1_IDX:%.*]] = mul nsw i64 [[X]], 400
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr getelementptr inbounds (i8, ptr @glob, i64 134), i64 [[GEP1_IDX]]
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr getelementptr inbounds nuw (i8, ptr @glob, i64 134), i64 [[GEP1_IDX]]
; CHECK-NEXT: [[GEP2_IDX:%.*]] = mul nsw i64 [[X]], 400
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr getelementptr inbounds (i8, ptr @glob, i64 132), i64 [[GEP2_IDX]]
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr getelementptr inbounds nuw (i8, ptr @glob, i64 132), i64 [[GEP2_IDX]]
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[GEP1]], align 4
; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[GEP2]], align 4
; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[B]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ define i32 @test_cast_gep_large_indices_as() {

define i32 @test_constant_cast_gep_struct_indices_as() {
; CHECK-LABEL: @test_constant_cast_gep_struct_indices_as(
; CHECK-NEXT: [[Y:%.*]] = load i32, ptr addrspace(3) getelementptr inbounds (i8, ptr addrspace(3) @constant_fold_global_ptr, i16 16), align 4
; CHECK-NEXT: [[Y:%.*]] = load i32, ptr addrspace(3) getelementptr inbounds nuw (i8, ptr addrspace(3) @constant_fold_global_ptr, i16 16), align 4
; CHECK-NEXT: ret i32 [[Y]]
;
%x = getelementptr %struct.foo, ptr addrspace(3) @constant_fold_global_ptr, i18 0, i32 2, i12 2
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/Transforms/InstCombine/constant-fold-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ target datalayout = "E-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-
define void @frob() {
; CHECK-LABEL: @frob(
; CHECK-NEXT: store i32 1, ptr @Y, align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 4), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 8), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 12), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 16), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 20), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 24), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 28), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 32), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 36), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 40), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 44), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 48), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 52), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 56), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 60), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 64), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 68), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds (i8, ptr @Y, i64 72), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 4), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 8), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 12), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 16), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 20), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 24), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 28), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 32), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 36), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 40), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 44), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 48), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 52), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 56), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 60), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 64), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 68), align 4
; CHECK-NEXT: store i32 1, ptr getelementptr inbounds nuw (i8, ptr @Y, i64 72), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr (i8, ptr @Y, i64 144), align 8
; CHECK-NEXT: store i32 1, ptr getelementptr (i8, ptr @Y, i64 76), align 8
; CHECK-NEXT: ret void
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstCombine/fmul.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ for.body:

define double @fmul_negated_constant_expression(double %x) {
; CHECK-LABEL: @fmul_negated_constant_expression(
; CHECK-NEXT: [[FSUB:%.*]] = fneg double bitcast (i64 ptrtoint (ptr getelementptr inbounds (i8, ptr @g, i64 16) to i64) to double)
; CHECK-NEXT: [[FSUB:%.*]] = fneg double bitcast (i64 ptrtoint (ptr getelementptr inbounds nuw (i8, ptr @g, i64 16) to i64) to double)
; CHECK-NEXT: [[R:%.*]] = fmul double [[X:%.*]], [[FSUB]]
; CHECK-NEXT: ret double [[R]]
;
Expand Down
Loading
Loading