================
@@ -0,0 +1,232 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o 
%t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o 
%t-cir.ll
+// RUN: FileCheck --check-prefixes=LLVM,LLVMCIR --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefixes=LLVM,OGCG --input-file=%t.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv-pointer -fclangir 
-emit-cir %s -o %t-wrapv.cir
+// RUN: FileCheck --check-prefix=WRAPV-CIR --input-file=%t-wrapv.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv-pointer -fclangir 
-emit-llvm %s -o %t-wrapv-cir.ll
+// RUN: FileCheck --check-prefixes=WRAPV-LLVM,WRAPV-LLVMCIR 
--input-file=%t-wrapv-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv-pointer -emit-llvm 
%s -o %t-wrapv.ll
+// RUN: FileCheck --check-prefixes=WRAPV-LLVM,WRAPV-OGCG 
--input-file=%t-wrapv.ll %s
+
+int signed_index(int i) {
+  int a[4] = {0};
+  return a[i];
+}
+
+// CIR-LABEL: cir.func {{.*}} @signed_index(
+// CIR:         %[[A:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.array<!s32i 
x 4>>
+// CIR:         %[[IDX:.*]] = cir.cast integral %{{.*}} : !s32i -> !s64i
+// CIR:         cir.get_element inbounds %[[A]][%[[IDX]] : !s64i] : 
!cir.ptr<!cir.array<!s32i x 4>> -> !cir.ptr<!s32i>
+
+// LLVM-LABEL: define dso_local i32 @signed_index(
+// LLVM:         %[[A:.*]] = alloca [4 x i32], align 16
+// LLVM:         %[[IDX:.*]] = sext i32 %{{.*}} to i64
+// LLVM:         getelementptr inbounds [4 x i32], ptr %[[A]],
+// LLVMCIR-SAME:   i32 0,
+// OGCG-SAME:      i64 0,
----------------
andykaylor wrote:

We should do something about this soon.

https://github.com/llvm/llvm-project/pull/234774
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to