brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 85b7dc3 Raw
71 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 62; RUN: opt -passes=gvn -S < %s | FileCheck %s3;4; The Global Value Numbering pass (GVN) propagates boolean values5; that are constant in dominated basic blocks to all the uses6; in these basic blocks. However, we don't want the constant propagated7; into fake.use intrinsics since this would render the intrinsic useless8; with respect to keeping the variable live up until the fake.use.9; This test checks that we don't generate any fake.uses with constant 0.10;11; Reduced from the following test case, generated with clang -O2 -S -emit-llvm -fextend-variable-liveness test.c12;13; extern void func1();14; extern int bar();15; extern void baz(int);16;17; int foo(int i, float f, int *punused)18; {19;   int j = 3*i;20;   if (j > 0) {21;     int m = bar(i);22;     if (m) {23;       char b = f;24;       baz(b);25;       if (b)26;         goto lab;27;       func1();28;     }29; lab:30;     func1();31;   }32;   return 1;33; }34 35;; GVN should propagate a constant value through to a regular call, but not to36;; a fake use, which should continue to track the original value.37 38define i32 @foo(float %f) optdebug {39; CHECK-LABEL: define i32 @foo(40; CHECK-SAME: float [[F:%.*]]) #[[ATTR0:[0-9]+]] {41; CHECK-NEXT:    [[CONV:%.*]] = fptosi float [[F]] to i842; CHECK-NEXT:    [[TOBOOL3:%.*]] = icmp eq i8 [[CONV]], 043; CHECK-NEXT:    br i1 [[TOBOOL3]], label %[[IF_END:.*]], label %[[LAB:.*]]44; CHECK:       [[IF_END]]:45; CHECK-NEXT:    tail call void (...) @bees(i8 0)46; CHECK-NEXT:    tail call void (...) @llvm.fake.use(i8 [[CONV]])47; CHECK-NEXT:    br label %[[LAB]]48; CHECK:       [[LAB]]:49; CHECK-NEXT:    ret i32 150;51  %conv = fptosi float %f to i852  %tobool3 = icmp eq i8 %conv, 053  br i1 %tobool3, label %if.end, label %lab54 55if.end:56  tail call void (...) @bees(i8 %conv)57  tail call void (...) @llvm.fake.use(i8 %conv)58  br label %lab59 60lab:61  ret i32 162}63 64declare i32 @bar(...)65 66declare void @baz(i32)67 68declare void @bees(i32)69 70declare void @func1(...)71