[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / constantexpr-fneg.c
blobfb7a3d1a695393a900f023c9bbd103320a358cf9
1 // RUN: %clang_cc1 -emit-llvm-bc -disable-llvm-passes -o %t.bc %s
2 // RUN: llvm-dis %t.bc -o - | FileCheck %s
4 // Test case for PR45426. Make sure we do not crash while writing bitcode
5 // containing a simplify-able fneg constant expression.
6 //
7 // CHECK-LABEL define i32 @main()
8 // CHECK: entry:
9 // CHECK-NEXT: %retval = alloca i32
10 // CHECK-NEXT: store i32 0, ptr %retval
11 // CHECK-NEXT: [[CMP:%.*]] = icmp ne ptr @b, @a
12 // CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMP]] to i32
13 // CHECK-NEXT: [[SITOFP:%.*]] = sitofp i32 [[ZEXT]] to float
14 // CHECK-NEXT: [[LV:%.*]] = load ptr, ptr @c
15 // CHECK-NEXT: store float [[SITOFP]], ptr [[LV]], align 4
16 // CHECK-NEXT: [[FNEG:%.*]] = fneg float [[SITOFP]]
17 // CHECK-NEXT: [[CONV:%.*]] = fptosi float [[FNEG]] to i32
18 // CHECK-NEXT: ret i32 [[CONV]]
20 int a[], b;
21 float *c;
22 int main(void) {
23 return -(*c = &b != a);