diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll index c03c9d69051edd..30b9fca6e97ada 100644 --- a/llvm/test/Transforms/InstCombine/and-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll @@ -5042,6 +5042,66 @@ define i1 @isnormal_logical_select_0_fmf1(half %x) { ret i1 %and } +define i1 @and_fcmp_reassoc1(i1 %x, double %a, double %b) { +; CHECK-LABEL: @and_fcmp_reassoc1( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[RETVAL]], [[CMP1]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp ult double %a, %b + %cmp1 = fcmp ugt double %a, %b + %and = and i1 %cmp, %x + %retval = and i1 %and, %cmp1 + ret i1 %retval +} + +define i1 @and_fcmp_reassoc2(i1 %x, double %a, double %b) { +; CHECK-LABEL: @and_fcmp_reassoc2( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[X:%.*]], [[TMP1]] +; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[RETVAL]], [[CMP1]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp ult double %a, %b + %cmp1 = fcmp ugt double %a, %b + %and = and i1 %x, %cmp + %retval = and i1 %and, %cmp1 + ret i1 %retval +} + +define i1 @and_fcmp_reassoc3(i1 %x, double %a, double %b) { +; CHECK-LABEL: @and_fcmp_reassoc3( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[CMP1]], [[RETVAL]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp ult double %a, %b + %cmp1 = fcmp ugt double %a, %b + %and = and i1 %cmp, %x + %retval = and i1 %cmp1, %and + ret i1 %retval +} + +define i1 @and_fcmp_reassoc4(i1 %x, double %a, double %b) { +; CHECK-LABEL: @and_fcmp_reassoc4( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ugt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = and i1 [[X:%.*]], [[TMP1]] +; CHECK-NEXT: [[RETVAL1:%.*]] = and i1 [[CMP1]], [[RETVAL]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp ult double %a, %b + %cmp1 = fcmp ugt double %a, %b + %and = and i1 %x, %cmp + %retval = and i1 %cmp1, %and + ret i1 %retval +} + declare half @llvm.fabs.f16(half) declare <2 x half> @llvm.fabs.v2f16(<2 x half>) declare half @llvm.copysign.f16(half, half) diff --git a/llvm/test/Transforms/InstCombine/or-fcmp.ll b/llvm/test/Transforms/InstCombine/or-fcmp.ll index 285b2d958abd8c..a2842f7a45f597 100644 --- a/llvm/test/Transforms/InstCombine/or-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/or-fcmp.ll @@ -4605,3 +4605,63 @@ define i1 @intersect_fmf_4(double %a, double %b) { %retval = or i1 %cmp, %cmp1 ret i1 %retval } + +define i1 @or_fcmp_reassoc1(i1 %x, double %a, double %b) { +; CHECK-LABEL: @or_fcmp_reassoc1( +; CHECK-NEXT: [[OR:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP2:%.*]] = fcmp ogt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[OR]], [[CMP1:%.*]] +; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[RETVAL]], [[CMP2]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp olt double %a, %b + %cmp1 = fcmp ogt double %a, %b + %or = or i1 %cmp, %x + %retval = or i1 %or, %cmp1 + ret i1 %retval +} + +define i1 @or_fcmp_reassoc2(i1 %x, double %a, double %b) { +; CHECK-LABEL: @or_fcmp_reassoc2( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[X:%.*]], [[TMP1]] +; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[RETVAL]], [[CMP1]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp olt double %a, %b + %cmp1 = fcmp ogt double %a, %b + %or = or i1 %x, %cmp + %retval = or i1 %or, %cmp1 + ret i1 %retval +} + +define i1 @or_fcmp_reassoc3(i1 %x, double %a, double %b) { +; CHECK-LABEL: @or_fcmp_reassoc3( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[CMP1]], [[RETVAL]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp olt double %a, %b + %cmp1 = fcmp ogt double %a, %b + %or = or i1 %cmp, %x + %retval = or i1 %cmp1, %or + ret i1 %retval +} + +define i1 @or_fcmp_reassoc4(i1 %x, double %a, double %b) { +; CHECK-LABEL: @or_fcmp_reassoc4( +; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[A]], [[B]] +; CHECK-NEXT: [[RETVAL:%.*]] = or i1 [[X:%.*]], [[TMP1]] +; CHECK-NEXT: [[RETVAL1:%.*]] = or i1 [[CMP1]], [[RETVAL]] +; CHECK-NEXT: ret i1 [[RETVAL1]] +; + %cmp = fcmp olt double %a, %b + %cmp1 = fcmp ogt double %a, %b + %or = or i1 %x, %cmp + %retval = or i1 %cmp1, %or + ret i1 %retval +}