1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=separate-const-offset-from-gep < %s | FileCheck %s
4 define void @matchingExtensions(ptr %ap, ptr %bp, ptr %result) {
5 ; CHECK-LABEL: @matchingExtensions(
7 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[AP:%.*]], align 4
8 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[BP:%.*]], align 4
9 ; CHECK-NEXT: [[EB:%.*]] = sext i32 [[B]] to i64
10 ; CHECK-NEXT: [[SUBAB:%.*]] = sub nsw i32 [[A]], [[B]]
11 ; CHECK-NEXT: [[EA:%.*]] = sext i32 [[A]] to i64
12 ; CHECK-NEXT: [[ADDEAEB:%.*]] = add nsw i64 [[EA]], [[EB]]
13 ; CHECK-NEXT: [[EXTSUB:%.*]] = sext i32 [[SUBAB]] to i64
14 ; CHECK-NEXT: [[IDX:%.*]] = getelementptr i32, ptr [[AP]], i64 [[EXTSUB]]
15 ; CHECK-NEXT: store i64 [[ADDEAEB]], ptr [[RESULT:%.*]]
16 ; CHECK-NEXT: store i32 [[SUBAB]], ptr [[IDX]]
17 ; CHECK-NEXT: ret void
20 %a = load i32, ptr %ap
21 %b = load i32, ptr %bp
22 %eb = sext i32 %b to i64
23 %subab = sub nsw i32 %a, %b
24 %ea = sext i32 %a to i64
25 %addeaeb = add nsw i64 %ea, %eb
26 %extsub = sext i32 %subab to i64
27 %idx = getelementptr i32, ptr %ap, i64 %extsub
28 store i64 %addeaeb, ptr %result
29 store i32 %subab, ptr %idx