@@ -48,13 +48,41 @@ void *f4(void *a, int b) { return a - b; }
48
48
// Similar to f4, just make sure it does not crash.
49
49
void * f4_1 (void * a , int b ) { return (a -= b ); }
50
50
51
+ FP f5 (FP a , int b ) { return a + b ; }
52
+ // CIR-LABEL: f5
53
+ // CIR: %[[PTR:.*]] = cir.load {{.*}} : !cir.ptr<!cir.ptr<!cir.func<!void ()>>>, !cir.ptr<!cir.func<!void ()>>
54
+ // CIR: %[[STRIDE:.*]] = cir.load {{.*}} : !cir.ptr<!s32i>, !s32i
55
+ // CIR: cir.ptr_stride(%[[PTR]] : !cir.ptr<!cir.func<!void ()>>, %[[STRIDE]] : !s32i)
56
+
57
+ // LLVM-LABEL: f5
58
+ // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8
59
+ // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4
60
+ // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64
61
+ // LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[STRIDE]]
62
+
63
+ // These test the same paths above, just make sure it does not crash.
64
+ FP f5_1 (FP a , int b ) { return (a += b ); }
65
+ FP f6 (int a , FP b ) { return a + b ; }
66
+ FP f6_1 (int a , FP b ) { return (a += b ); }
67
+
68
+ FP f7 (FP a , int b ) { return a - b ; }
69
+ // CIR-LABEL: f7
70
+ // CIR: %[[PTR:.*]] = cir.load {{.*}} : !cir.ptr<!cir.ptr<!cir.func<!void ()>>>, !cir.ptr<!cir.func<!void ()>>
71
+ // CIR: %[[STRIDE:.*]] = cir.load {{.*}} : !cir.ptr<!s32i>, !s32i
72
+ // CIR: %[[SUB:.*]] = cir.unary(minus, %[[STRIDE]]) : !s32i, !s32i
73
+ // CIR: cir.ptr_stride(%[[PTR]] : !cir.ptr<!cir.func<!void ()>>, %[[SUB]] : !s32i)
74
+
75
+ // LLVM-LABEL: f7
76
+ // LLVM: %[[PTR:.*]] = load ptr, ptr {{.*}}, align 8
77
+ // LLVM: %[[TOEXT:.*]] = load i32, ptr {{.*}}, align 4
78
+ // LLVM: %[[STRIDE:.*]] = sext i32 %[[TOEXT]] to i64
79
+ // LLVM: %[[SUB:.*]] = sub i64 0, %[[STRIDE]]
80
+ // LLVM: getelementptr i8, ptr %[[PTR]], i64 %[[SUB]]
81
+
82
+ // Similar to f7, just make sure it does not crash.
83
+ FP f7_1 (FP a , int b ) { return (a -= b ); }
84
+
51
85
// FIXME: add support for the remaining ones.
52
- // FP f5(FP a, int b) { return a + b; }
53
- // FP f5_1(FP a, int b) { return (a += b); }
54
- // FP f6(int a, FP b) { return a + b; }
55
- // FP f6_1(int a, FP b) { return (a += b); }
56
- // FP f7(FP a, int b) { return a - b; }
57
- // FP f7_1(FP a, int b) { return (a -= b); }
58
86
// void f8(void *a, int b) { return *(a + b); }
59
87
// void f8_1(void *a, int b) { return a[b]; }
60
88
@@ -69,4 +97,4 @@ unsigned char *p(unsigned int x) {
69
97
// CIR: cir.ptr_stride({{.*}} : !cir.ptr<!u8i>, %[[SUB]] : !u32i), !cir.ptr<!u8i>
70
98
71
99
// LLVM-LABEL: @p
72
- // LLVM: getelementptr i8, ptr {{.*}}
100
+ // LLVM: getelementptr i8, ptr {{.*}}
0 commit comments