(The 'nnan' variant of this pattern is already tested to produce '1.0'.)
https://alive2.llvm.org/ce/z/D4hPBy
define i1 @src(float %x, i32 %y) {
%0:
%d = fdiv float %x, %x
%uge = fcmp uge float %d, 0.000000
ret i1 %uge
}
=>
define i1 @tgt(float %x, i32 %y) {
%0:
ret i1 1
}
Transformation seems to be correct!
case Instruction::UIToFP:
return true;
case Instruction::FMul:
- // x*x is always non-negative or a NaN.
+ case Instruction::FDiv:
+ // X * X is always non-negative or a NaN.
+ // X / X is always exactly 1.0 or a NaN.
if (I->getOperand(0) == I->getOperand(1) &&
(!SignBitOnly || cast<FPMathOperator>(I)->hasNoNaNs()))
return true;
LLVM_FALLTHROUGH;
case Instruction::FAdd:
- case Instruction::FDiv:
case Instruction::FRem:
return cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI, SignBitOnly,
Depth + 1) &&
define i1 @orderedLessZero_fdiv(float %x) {
; CHECK-LABEL: @orderedLessZero_fdiv(
-; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], [[X]]
-; CHECK-NEXT: [[UGE:%.*]] = fcmp uge float [[D]], 0.000000e+00
-; CHECK-NEXT: ret i1 [[UGE]]
+; CHECK-NEXT: ret i1 true
;
%d = fdiv float %x, %x
%uge = fcmp uge float %d, 0.0