Skip to content

Commit fb8014c

Browse files
committed
[InstCombine] Add more tests. NFC.
1 parent 5580ecd commit fb8014c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,8 +2677,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
26772677
IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
26782678
Builder.setFastMathFlags(II->getFastMathFlags() &
26792679
cast<Instruction>(Sign)->getFastMathFlags());
2680-
Value *CopySign =
2681-
Builder.CreateBinaryIntrinsic(Intrinsic::copysign, Mag, X);
2680+
Value *CopySign = Builder.CreateCopySign(Mag, X);
26822681
return replaceInstUsesWith(*II, CopySign);
26832682
}
26842683

llvm/test/Transforms/InstCombine/copysign.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ define float @copysign_sign_arg_nnan(float %x, float %y, float %z) {
100100
ret float %r
101101
}
102102

103+
define float @copysign_sign_arg_mixed(float %x, float %y, float %z) {
104+
; CHECK-LABEL: @copysign_sign_arg_mixed(
105+
; CHECK-NEXT: [[R:%.*]] = call nsz float @llvm.copysign.f32(float [[X:%.*]], float [[Z:%.*]])
106+
; CHECK-NEXT: ret float [[R]]
107+
;
108+
%s = call ninf nsz float @llvm.copysign.f32(float %y, float %z)
109+
%r = call nnan nsz float @llvm.copysign.f32(float %x, float %s)
110+
ret float %r
111+
}
112+
103113
define float @fneg_mag(float %x, float %y) {
104114
; CHECK-LABEL: @fneg_mag(
105115
; CHECK-NEXT: [[R:%.*]] = call float @llvm.copysign.f32(float [[X:%.*]], float [[Y:%.*]])

0 commit comments

Comments
 (0)