Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 19e7571

Browse files
atrosinenkoasl
authored andcommitted
[MSP430] Declare comparison LibCalls as returning i16 instead of i32
For TI's distribution of msp430-gcc ``` msp430-elf-gcc -S -o- -Os -x c - <<< "int f(float a, float b) { return a != b; }" ``` does not mention `R13` at all. `__libgcc_cmp_return__` machine mode is 2 byte on MSP430, as well. Differential Revision: https://reviews.llvm.org/D82635
1 parent 4f5133a commit 19e7571

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

llvm/lib/Target/MSP430/MSP430ISelLowering.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ namespace llvm {
7979
return MVT::i8;
8080
}
8181

82+
MVT::SimpleValueType getCmpLibcallReturnType() const override {
83+
return MVT::i16;
84+
}
85+
8286
/// LowerOperation - Provide custom lowering hooks for some operations.
8387
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
8488

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: llc < %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
4+
target triple = "msp430"
5+
6+
define i16 @f(float %a, float %b) optsize {
7+
%cmp = fcmp une float %a, %b
8+
%conv = zext i1 %cmp to i16
9+
; CHECK-LABEL: call #__mspabi_cmpf
10+
; CHECK-NOT: r13
11+
; CHECK-LABEL: mov r2
12+
13+
; This is quite fragile attempt to detect the return type:
14+
; Correct:
15+
; call #__mspabi_cmpf
16+
; tst r12
17+
; mov r2, r13
18+
; Incorrect:
19+
; call #__mspabi_cmpf
20+
; bis r12, r13 <-- checking (R12:R13)
21+
; tst r13
22+
; mov r2, r13
23+
24+
ret i16 %conv
25+
}

0 commit comments

Comments
 (0)