Skip to content

Commit 7263cd4

Browse files
authored
[LegalizeTypes][MSP430] Soften FAKE_USE operand (#142714)
Adds support for softening FAKE_USE operands. Adds MSP430 tests that exercise the new softening code. Fixes #137572
1 parent 9ab4c16 commit 7263cd4

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,9 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
11431143
Res = SoftenFloatOp_ATOMIC_STORE(N, OpNo);
11441144
break;
11451145
case ISD::FCOPYSIGN: Res = SoftenFloatOp_FCOPYSIGN(N); break;
1146+
case ISD::FAKE_USE:
1147+
Res = SoftenFloatOp_FAKE_USE(N);
1148+
break;
11461149
}
11471150

11481151
// If the result is null, the sub-method took care of registering results etc.
@@ -1477,6 +1480,12 @@ SDValue DAGTypeLegalizer::SoftenFloatOp_LLRINT(SDNode *N) {
14771480
RTLIB::LLRINT_PPCF128));
14781481
}
14791482

1483+
SDValue DAGTypeLegalizer::SoftenFloatOp_FAKE_USE(SDNode *N) {
1484+
SDValue Op1 = BitConvertToInteger(N->getOperand(1));
1485+
return DAG.getNode(N->getOpcode(), SDLoc(N), N->getValueType(0),
1486+
N->getOperand(0), Op1);
1487+
}
1488+
14801489
//===----------------------------------------------------------------------===//
14811490
// Float Result Expansion
14821491
//===----------------------------------------------------------------------===//

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
651651
SDValue SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
652652
SDValue SoftenFloatOp_ATOMIC_STORE(SDNode *N, unsigned OpNo);
653653
SDValue SoftenFloatOp_FCOPYSIGN(SDNode *N);
654+
SDValue SoftenFloatOp_FAKE_USE(SDNode *N);
654655

655656
//===--------------------------------------------------------------------===//
656657
// Float Expansion Support: LegalizeFloatTypes.cpp
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: llc < %s | FileCheck %s
2+
target triple = "msp430"
3+
4+
; CHECK: mov #19923, r12
5+
; CHECK: mov #4194, r12
6+
; CHECK: mov #25688, r12
7+
; CHECK: mov #-16245, r12
8+
; CHECK: ret
9+
define void @test-double() {
10+
entry:
11+
call void (...) @llvm.fake.use(double -8.765430e+02)
12+
ret void
13+
}
14+
15+
; CHECK: call #__mspabi_addd
16+
; CHECK: ret
17+
define void @test-double2(double %0) {
18+
entry:
19+
%1 = fadd double %0, %0
20+
call void (...) @llvm.fake.use(double %1)
21+
ret void
22+
}
23+
24+
; CHECK: call #__mspabi_addf
25+
; CHECK: ret
26+
define void @test-float(float %0) {
27+
entry:
28+
%1 = fadd float %0, %0
29+
call void (...) @llvm.fake.use(float %1)
30+
ret void
31+
}

0 commit comments

Comments
 (0)