// type of OpI doesn't enter into things at all. We simply evaluate
// in whichever source type is larger, then convert to the
// destination type.
- Value *NewLHS = LHSOrig, *NewRHS = RHSOrig;
if (LHSWidth < SrcWidth)
- NewLHS = Builder->CreateFPExt(NewLHS, RHSOrig->getType());
+ LHSOrig = Builder->CreateFPExt(LHSOrig, RHSOrig->getType());
else if (RHSWidth <= SrcWidth)
- NewRHS = Builder->CreateFPExt(NewRHS, LHSOrig->getType());
- if (NewLHS != LHSOrig || NewRHS != RHSOrig) {
- Value *ExactResult = Builder->CreateFRem(NewLHS, NewRHS);
+ RHSOrig = Builder->CreateFPExt(RHSOrig, LHSOrig->getType());
+ if (LHSOrig != OpI->getOperand(0) || RHSOrig != OpI->getOperand(1)) {
+ Value *ExactResult = Builder->CreateFRem(LHSOrig, RHSOrig);
if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
RI->copyFastMathFlags(OpI);
return CastInst::CreateFPCast(ExactResult, CI.getType());
; CHECK-NEXT: %[[trunc:.*]] = fptrunc <1 x double> %[[frem]] to <1 x float>
; CHECK-NEXT: ret <1 x float> %trunc
}
+
+define float @test7(double %V) {
+ %frem = frem double %V, 1.000000e+00
+ %trunc = fptrunc double %frem to float
+ ret float %trunc
+; CHECK-LABEL: @test7
+; CHECK-NEXT: %[[frem:.*]] = frem double %V, 1.000000e+00
+; CHECK-NEXT: %[[trunc:.*]] = fptrunc double %frem to float
+; CHECK-NEXT: ret float %trunc
+}