Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCVISelLowering] avoid emitting libcalls to __mulodi4() and __mult…
…i3() Similar to D108842, D108844, D108926, D108928, and D108936. __has_builtin(builtin_mul_overflow) returns true for 32b RISCV targets, but Clang is deferring to compiler RT when encountering long long types. If the semantics of __has_builtin mean "the compiler resolves these, always" then we shouldn't conditionally emit a libcall. Link: https://bugs.llvm.org/show_bug.cgi?id=28629 Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D108939
- Loading branch information
1 parent
bf8b69b
commit e9b3f25
Showing
5 changed files
with
909 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
llvm/test/CodeGen/RISCV/overflow-intrinsic-optimizations.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; RUN: llc %s -mtriple=riscv32 -o - | FileCheck %s | ||
|
||
define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) { | ||
; CHECK-LABEL: no__mulodi4 | ||
; CHECK-NOT: call __mulodi4@plt | ||
; CHECK-NOT: call __multi3@plt | ||
entry: | ||
%0 = sext i32 %a to i64 | ||
%1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b) | ||
%2 = extractvalue { i64, i1 } %1, 1 | ||
%3 = extractvalue { i64, i1 } %1, 0 | ||
%4 = trunc i64 %3 to i32 | ||
%5 = sext i32 %4 to i64 | ||
%6 = icmp ne i64 %3, %5 | ||
%7 = or i1 %2, %6 | ||
store i32 %4, i32* %c, align 4 | ||
ret i1 %7 | ||
} | ||
|
||
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64) |
Oops, something went wrong.