| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 5 |
| ; Two-entry phi nodes with unpredictable conditions may get increased budget for folding. |
| ; RUN: opt < %s -S -passes=simplifycfg | FileCheck --check-prefix=CHECK-NOFOLD %s |
| ; RUN: opt < %s -S -passes='simplifycfg<speculate-unpredictables>' | FileCheck --check-prefix=CHECK-NOFOLD %s |
| ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 < %s -S -passes=simplifycfg | FileCheck --check-prefix=CHECK-NOFOLD %s |
| ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 < %s -S -passes='simplifycfg<speculate-unpredictables>' | FileCheck --check-prefix=CHECK-FOLD %s |
| |
| define { <2 x float>, <2 x float> } @foo(float %arg, <2 x float> %arg1, <2 x float> %arg2) #0 { |
| ; CHECK-NOFOLD-LABEL: define { <2 x float>, <2 x float> } @foo( |
| ; CHECK-NOFOLD-SAME: float [[ARG:%.*]], <2 x float> [[ARG1:%.*]], <2 x float> [[ARG2:%.*]]) #[[ATTR0:[0-9]+]] { |
| ; CHECK-NOFOLD-NEXT: [[BB:.*]]: |
| ; CHECK-NOFOLD-NEXT: [[I:%.*]] = fcmp fast ogt float [[ARG]], 0x3F747AE140000000 |
| ; CHECK-NOFOLD-NEXT: br i1 [[I]], label %[[BB3:.*]], label %[[BB20:.*]], !unpredictable [[META0:![0-9]+]] |
| ; CHECK-NOFOLD: [[BB3]]: |
| ; CHECK-NOFOLD-NEXT: [[I4:%.*]] = extractelement <2 x float> [[ARG1]], i64 0 |
| ; CHECK-NOFOLD-NEXT: [[I5:%.*]] = fmul fast float [[I4]], [[I4]] |
| ; CHECK-NOFOLD-NEXT: [[I6:%.*]] = extractelement <2 x float> [[ARG1]], i64 1 |
| ; CHECK-NOFOLD-NEXT: [[I7:%.*]] = fmul fast float [[I6]], [[I6]] |
| ; CHECK-NOFOLD-NEXT: [[I8:%.*]] = fadd fast float [[I7]], [[I5]] |
| ; CHECK-NOFOLD-NEXT: [[I9:%.*]] = extractelement <2 x float> [[ARG2]], i64 0 |
| ; CHECK-NOFOLD-NEXT: [[I10:%.*]] = fmul fast float [[I9]], [[I9]] |
| ; CHECK-NOFOLD-NEXT: [[I11:%.*]] = fadd fast float [[I8]], [[I10]] |
| ; CHECK-NOFOLD-NEXT: [[I12:%.*]] = tail call fast noundef float @llvm.sqrt.f32(float [[I11]]) |
| ; CHECK-NOFOLD-NEXT: [[I13:%.*]] = fdiv fast float 0x3FEFD70A40000000, [[I12]] |
| ; CHECK-NOFOLD-NEXT: [[I14:%.*]] = fmul fast float [[I13]], [[I4]] |
| ; CHECK-NOFOLD-NEXT: [[I15:%.*]] = insertelement <2 x float> poison, float [[I14]], i64 0 |
| ; CHECK-NOFOLD-NEXT: [[I16:%.*]] = fmul fast float [[I13]], [[I6]] |
| ; CHECK-NOFOLD-NEXT: [[I17:%.*]] = insertelement <2 x float> [[I15]], float [[I16]], i64 1 |
| ; CHECK-NOFOLD-NEXT: [[I18:%.*]] = fmul fast float [[I13]], [[I9]] |
| ; CHECK-NOFOLD-NEXT: [[I19:%.*]] = insertelement <2 x float> [[ARG2]], float [[I18]], i64 0 |
| ; CHECK-NOFOLD-NEXT: br label %[[BB20]] |
| ; CHECK-NOFOLD: [[BB20]]: |
| ; CHECK-NOFOLD-NEXT: [[I21:%.*]] = phi nsz <2 x float> [ [[I17]], %[[BB3]] ], [ zeroinitializer, %[[BB]] ] |
| ; CHECK-NOFOLD-NEXT: [[I22:%.*]] = phi nsz <2 x float> [ [[I19]], %[[BB3]] ], [ zeroinitializer, %[[BB]] ] |
| ; CHECK-NOFOLD-NEXT: [[I23:%.*]] = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> [[I21]], 0 |
| ; CHECK-NOFOLD-NEXT: [[I24:%.*]] = insertvalue { <2 x float>, <2 x float> } [[I23]], <2 x float> [[I22]], 1 |
| ; CHECK-NOFOLD-NEXT: ret { <2 x float>, <2 x float> } [[I24]] |
| ; |
| ; CHECK-FOLD-LABEL: define { <2 x float>, <2 x float> } @foo( |
| ; CHECK-FOLD-SAME: float [[ARG:%.*]], <2 x float> [[ARG1:%.*]], <2 x float> [[ARG2:%.*]]) #[[ATTR0:[0-9]+]] { |
| ; CHECK-FOLD-NEXT: [[BB:.*:]] |
| ; CHECK-FOLD-NEXT: [[I:%.*]] = fcmp fast ogt float [[ARG]], 0x3F747AE140000000 |
| ; CHECK-FOLD-NEXT: [[I4:%.*]] = extractelement <2 x float> [[ARG1]], i64 0 |
| ; CHECK-FOLD-NEXT: [[I5:%.*]] = fmul fast float [[I4]], [[I4]] |
| ; CHECK-FOLD-NEXT: [[I6:%.*]] = extractelement <2 x float> [[ARG1]], i64 1 |
| ; CHECK-FOLD-NEXT: [[I7:%.*]] = fmul fast float [[I6]], [[I6]] |
| ; CHECK-FOLD-NEXT: [[I8:%.*]] = fadd fast float [[I7]], [[I5]] |
| ; CHECK-FOLD-NEXT: [[I9:%.*]] = extractelement <2 x float> [[ARG2]], i64 0 |
| ; CHECK-FOLD-NEXT: [[I10:%.*]] = fmul fast float [[I9]], [[I9]] |
| ; CHECK-FOLD-NEXT: [[I11:%.*]] = fadd fast float [[I8]], [[I10]] |
| ; CHECK-FOLD-NEXT: [[I12:%.*]] = tail call fast float @llvm.sqrt.f32(float [[I11]]) |
| ; CHECK-FOLD-NEXT: [[I13:%.*]] = fdiv fast float 0x3FEFD70A40000000, [[I12]] |
| ; CHECK-FOLD-NEXT: [[I14:%.*]] = fmul fast float [[I13]], [[I4]] |
| ; CHECK-FOLD-NEXT: [[I15:%.*]] = insertelement <2 x float> poison, float [[I14]], i64 0 |
| ; CHECK-FOLD-NEXT: [[I16:%.*]] = fmul fast float [[I13]], [[I6]] |
| ; CHECK-FOLD-NEXT: [[I17:%.*]] = insertelement <2 x float> [[I15]], float [[I16]], i64 1 |
| ; CHECK-FOLD-NEXT: [[I18:%.*]] = fmul fast float [[I13]], [[I9]] |
| ; CHECK-FOLD-NEXT: [[I19:%.*]] = insertelement <2 x float> [[ARG2]], float [[I18]], i64 0 |
| ; CHECK-FOLD-NEXT: [[I21:%.*]] = select nsz i1 [[I]], <2 x float> [[I17]], <2 x float> zeroinitializer, !unpredictable [[META0:![0-9]+]] |
| ; CHECK-FOLD-NEXT: [[I22:%.*]] = select nsz i1 [[I]], <2 x float> [[I19]], <2 x float> zeroinitializer, !unpredictable [[META0]] |
| ; CHECK-FOLD-NEXT: [[I23:%.*]] = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> [[I21]], 0 |
| ; CHECK-FOLD-NEXT: [[I24:%.*]] = insertvalue { <2 x float>, <2 x float> } [[I23]], <2 x float> [[I22]], 1 |
| ; CHECK-FOLD-NEXT: ret { <2 x float>, <2 x float> } [[I24]] |
| ; |
| bb: |
| %i = fcmp fast ogt float %arg, 0x3F747AE140000000 |
| br i1 %i, label %bb3, label %bb20, !unpredictable !0 |
| |
| bb3: ; preds = %bb |
| %i4 = extractelement <2 x float> %arg1, i64 0 |
| %i5 = fmul fast float %i4, %i4 |
| %i6 = extractelement <2 x float> %arg1, i64 1 |
| %i7 = fmul fast float %i6, %i6 |
| %i8 = fadd fast float %i7, %i5 |
| %i9 = extractelement <2 x float> %arg2, i64 0 |
| %i10 = fmul fast float %i9, %i9 |
| %i11 = fadd fast float %i8, %i10 |
| %i12 = tail call fast noundef float @llvm.sqrt.f32(float %i11) |
| %i13 = fdiv fast float 0x3FEFD70A40000000, %i12 |
| %i14 = fmul fast float %i13, %i4 |
| %i15 = insertelement <2 x float> poison, float %i14, i64 0 |
| %i16 = fmul fast float %i13, %i6 |
| %i17 = insertelement <2 x float> %i15, float %i16, i64 1 |
| %i18 = fmul fast float %i13, %i9 |
| %i19 = insertelement <2 x float> %arg2, float %i18, i64 0 |
| br label %bb20 |
| |
| bb20: ; preds = %bb3, %bb |
| %i21 = phi nsz <2 x float> [ %i17, %bb3 ], [ zeroinitializer, %bb ] |
| %i22 = phi nsz <2 x float> [ %i19, %bb3 ], [ zeroinitializer, %bb ] |
| %i23 = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %i21, 0 |
| %i24 = insertvalue { <2 x float>, <2 x float> } %i23, <2 x float> %i22, 1 |
| ret { <2 x float>, <2 x float> } %i24 |
| } |
| |
| declare float @llvm.sqrt.f32(float) |
| |
| attributes #0 = { nounwind } |
| |
| !0 = !{} |