[llvm-branch-commits] [llvm-branch] r368674 - Merging r368572:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 13 05:00:39 PDT 2019
Author: hans
Date: Tue Aug 13 05:00:39 2019
New Revision: 368674
URL: http://llvm.org/viewvc/llvm-project?rev=368674&view=rev
Log:
Merging r368572:
------------------------------------------------------------------------
r368572 | lenary | 2019-08-12 15:51:00 +0200 (Mon, 12 Aug 2019) | 18 lines
[RISCV] Fix ICE in isDesirableToCommuteWithShift
Summary:
Ana Pazos reported a bug where we were not checking that an APInt would
fit into 64-bits before calling `getSExtValue()`. This caused asserts when
compiling large constants, such as i128s, as happens when compiling compiler-rt.
This patch adds a testcase and makes the callback less error-prone.
Reviewers: apazos, asb, luismarques
Reviewed By: luismarques
Subscribers: hiraditya, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66081
------------------------------------------------------------------------
Modified:
llvm/branches/release_90/ (props changed)
llvm/branches/release_90/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/branches/release_90/test/CodeGen/RISCV/add-before-shl.ll
Propchange: llvm/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 13 05:00:39 2019
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,366431,366481,366487,366527,366570,366660,366868,366925,367030,367062,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367417,367662,367750,367753,367846-367847,367898,367941,368004,368230,368315,368324,368517-368519,368554
+/llvm/trunk:155241,366431,366481,366487,366527,366570,366660,366868,366925,367030,367062,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367417,367662,367750,367753,367846-367847,367898,367941,368004,368230,368315,368324,368517-368519,368554,368572
Modified: llvm/branches/release_90/lib/Target/RISCV/RISCVISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/RISCV/RISCVISelLowering.cpp?rev=368674&r1=368673&r2=368674&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/RISCV/RISCVISelLowering.cpp (original)
+++ llvm/branches/release_90/lib/Target/RISCV/RISCVISelLowering.cpp Tue Aug 13 05:00:39 2019
@@ -1007,12 +1007,14 @@ bool RISCVTargetLowering::isDesirableToC
// We can materialise `c1 << c2` into an add immediate, so it's "free",
// and the combine should happen, to potentially allow further combines
// later.
- if (isLegalAddImmediate(ShiftedC1Int.getSExtValue()))
+ if (ShiftedC1Int.getMinSignedBits() <= 64 &&
+ isLegalAddImmediate(ShiftedC1Int.getSExtValue()))
return true;
// We can materialise `c1` in an add immediate, so it's "free", and the
// combine should be prevented.
- if (isLegalAddImmediate(C1Int.getSExtValue()))
+ if (C1Int.getMinSignedBits() <= 64 &&
+ isLegalAddImmediate(C1Int.getSExtValue()))
return false;
// Neither constant will fit into an immediate, so find materialisation
Modified: llvm/branches/release_90/test/CodeGen/RISCV/add-before-shl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/test/CodeGen/RISCV/add-before-shl.ll?rev=368674&r1=368673&r2=368674&view=diff
==============================================================================
--- llvm/branches/release_90/test/CodeGen/RISCV/add-before-shl.ll (original)
+++ llvm/branches/release_90/test/CodeGen/RISCV/add-before-shl.ll Tue Aug 13 05:00:39 2019
@@ -91,3 +91,43 @@ define signext i24 @add_non_machine_type
%2 = shl i24 %1, 12
ret i24 %2
}
+
+define i128 @add_wide_operand(i128 %a) nounwind {
+; RV32I-LABEL: add_wide_operand:
+; RV32I: # %bb.0:
+; RV32I-NEXT: lw a2, 0(a1)
+; RV32I-NEXT: srli a3, a2, 29
+; RV32I-NEXT: lw a4, 4(a1)
+; RV32I-NEXT: slli a5, a4, 3
+; RV32I-NEXT: or a6, a5, a3
+; RV32I-NEXT: srli a4, a4, 29
+; RV32I-NEXT: lw a5, 8(a1)
+; RV32I-NEXT: slli a3, a5, 3
+; RV32I-NEXT: or a3, a3, a4
+; RV32I-NEXT: slli a2, a2, 3
+; RV32I-NEXT: sw a2, 0(a0)
+; RV32I-NEXT: sw a3, 8(a0)
+; RV32I-NEXT: sw a6, 4(a0)
+; RV32I-NEXT: srli a2, a5, 29
+; RV32I-NEXT: lw a1, 12(a1)
+; RV32I-NEXT: slli a1, a1, 3
+; RV32I-NEXT: or a1, a1, a2
+; RV32I-NEXT: lui a2, 128
+; RV32I-NEXT: add a1, a1, a2
+; RV32I-NEXT: sw a1, 12(a0)
+; RV32I-NEXT: ret
+;
+; RV64I-LABEL: add_wide_operand:
+; RV64I: # %bb.0:
+; RV64I-NEXT: slli a1, a1, 3
+; RV64I-NEXT: srli a2, a0, 61
+; RV64I-NEXT: or a1, a1, a2
+; RV64I-NEXT: addi a2, zero, 1
+; RV64I-NEXT: slli a2, a2, 51
+; RV64I-NEXT: add a1, a1, a2
+; RV64I-NEXT: slli a0, a0, 3
+; RV64I-NEXT: ret
+ %1 = add i128 %a, 5192296858534827628530496329220096
+ %2 = shl i128 %1, 3
+ ret i128 %2
+}
More information about the llvm-branch-commits
mailing list