|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -S -passes=instcombine < %s | FileCheck %s |
| 3 | + |
| 4 | +; sinf clobbering errno, but %p cannot alias errno per C/C++ strict aliasing rules via TBAA. |
| 5 | +; Hence, can do constant store-to-load forwarding. |
| 6 | +define float @does_not_alias_errno(ptr noundef %p, float noundef %f) { |
| 7 | +; CHECK-LABEL: define float @does_not_alias_errno( |
| 8 | +; CHECK-SAME: ptr noundef [[P:%.*]], float noundef [[F:%.*]]) { |
| 9 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 10 | +; CHECK-NEXT: store float 0.000000e+00, ptr [[P]], align 4, !tbaa [[TBAA3:![0-9]+]] |
| 11 | +; CHECK-NEXT: [[CALL:%.*]] = call float @sinf(float noundef [[F]]), !tbaa [[TBAA5:![0-9]+]] |
| 12 | +; CHECK-NEXT: ret float 0.000000e+00 |
| 13 | +; |
| 14 | +entry: |
| 15 | + store float 0.000000e+00, ptr %p, align 4, !tbaa !3 |
| 16 | + %call = call float @sinf(float noundef %f), !tbaa !10 |
| 17 | + %0 = load float, ptr %p, align 4, !tbaa !3 |
| 18 | + ret float %0 |
| 19 | +} |
| 20 | + |
| 21 | +; sinf clobbering errno, unknown TBAA info, %p may alias errno |
| 22 | +define float @may_alias_errno(ptr noundef %p, float noundef %f) { |
| 23 | +; CHECK-LABEL: define float @may_alias_errno( |
| 24 | +; CHECK-SAME: ptr noundef [[P:%.*]], float noundef [[F:%.*]]) { |
| 25 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 26 | +; CHECK-NEXT: store float 0.000000e+00, ptr [[P]], align 4 |
| 27 | +; CHECK-NEXT: [[CALL:%.*]] = call float @sinf(float noundef [[F]]) |
| 28 | +; CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[P]], align 4 |
| 29 | +; CHECK-NEXT: ret float [[TMP0]] |
| 30 | +; |
| 31 | +entry: |
| 32 | + store float 0.000000e+00, ptr %p, align 4 |
| 33 | + %call = call float @sinf(float noundef %f) |
| 34 | + %0 = load float, ptr %p, align 4 |
| 35 | + ret float %0 |
| 36 | +} |
| 37 | + |
| 38 | +declare float @sinf(float noundef) #1 |
| 39 | + |
| 40 | +attributes #1 = { mustprogress nofree nounwind willreturn memory(errnomem: write) } |
| 41 | + |
| 42 | +!llvm.errno.tbaa = !{!0} |
| 43 | + |
| 44 | +!0 = !{!"int", !1, i64 0} |
| 45 | +!1 = !{!"omnipotent char", !2, i64 0} |
| 46 | +!2 = !{!"Simple C/C++ TBAA"} |
| 47 | +!3 = !{!4, !4, i64 0} |
| 48 | +!4 = !{!"float", !1, i64 0} |
| 49 | +!10 = !{!0, !0, i64 0} |
0 commit comments