The immediate cost calculation code was hitting an assertion in the included
test case, because APInt was still internally 128-bits. Truncating it to 64-bits
fixed the issue.
Fixes <rdar://problem/
16572521>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205947
91177308-0d34-0410-b5e6-
96231b3b80d8
// chunk.
unsigned Cost = 0;
for (unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) {
- APInt Tmp = ImmVal.ashr(ShiftVal).getLoBits(64);
+ APInt Tmp = ImmVal.ashr(ShiftVal).sextOrTrunc(64);
int64_t Val = Tmp.getSExtValue();
Cost += getIntImmCost(Val);
}
--- /dev/null
+; RUN: opt -mtriple=arm64-darwin-unknown -S -consthoist < %s | FileCheck %s
+
+define i128 @test1(i128 %a) nounwind {
+; CHECK-LABEL: test1
+; CHECK: %const = bitcast i128 12297829382473034410122878 to i128
+ %1 = add i128 %a, 12297829382473034410122878
+ %2 = add i128 %1, 12297829382473034410122878
+ ret i128 %2
+}
+