From ebf9bf2cbc8fa68d536e481e370c4ba40ce61a8a Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 17 Nov 2019 11:23:44 -0500 Subject: [SimplifyCFG] propagate fast-math-flags (FMF) from phi to select Similar to/extension of D70208 (rGee0882bdf866), but this one may finally allow closing motivating bugs. This is another step towards having FMF apply only to FP values rather than those + fcmp. See PR38086 for one of the original discussions/motivations: https://bugs.llvm.org/show_bug.cgi?id=38086 And the test here is derived from PR39535: https://bugs.llvm.org/show_bug.cgi?id=39535 Currently, we lose FMF when converting any phi to select in SimplifyCFG. There are a small number of similar changes needed to correct within SimplifyCFG, so it should be quick to patch this pass up. FMF was extended to select and phi with: D61917 D67564 --- llvm/test/Transforms/SimplifyCFG/speculate-math.ll | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'llvm/test/Transforms/SimplifyCFG/speculate-math.ll') diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll index 4c8d8b1e120..a99b86ae5d7 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll @@ -16,7 +16,7 @@ define double @fdiv_test(double %a, double %b) { ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]] -; ALL-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[DIV]], double 0.000000e+00 +; ALL-NEXT: [[COND:%.*]] = select nsz i1 [[CMP]], double [[DIV]], double 0.000000e+00 ; ALL-NEXT: ret double [[COND]] ; entry: @@ -37,7 +37,7 @@ define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nou ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.sqrt.f32(float [[A]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select afn i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -60,7 +60,7 @@ define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nou ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[A]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select reassoc i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -83,7 +83,7 @@ define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, floa ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fma.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select reassoc nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -106,7 +106,7 @@ define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fmuladd.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select ninf i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -152,7 +152,7 @@ define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, f ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maxnum.f32(float [[A]], float [[B:%.*]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select ninf nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -175,7 +175,7 @@ define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minimum.f32(float [[A]], float [[B:%.*]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select reassoc i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; @@ -198,7 +198,7 @@ define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, ; ALL-NEXT: entry: ; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 ; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maximum.f32(float [[A]], float [[B:%.*]]) #2 -; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: [[COND_I:%.*]] = select nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] ; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 ; ALL-NEXT: ret void ; -- cgit v1.2.3