[PATCH] D21668: [ARM] Fix cost computation for constant hoisting
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 11:01:08 PDT 2016
weimingz removed rL LLVM as the repository for this revision.
weimingz updated this revision to Diff 61811.
weimingz added a comment.
using ">=" because when convert to signed values, getMinSignedBits() may return 65. Instead of checking both activeBits and MinSignedBits(), we just check if activeBits() is no larger than 64.
http://reviews.llvm.org/D21668
Files:
lib/Target/ARM/ARMTargetTransformInfo.cpp
test/Transforms/ConstantHoisting/ARM/bad-cases.ll
Index: test/Transforms/ConstantHoisting/ARM/bad-cases.ll
===================================================================
--- test/Transforms/ConstantHoisting/ARM/bad-cases.ll
+++ test/Transforms/ConstantHoisting/ARM/bad-cases.ll
@@ -90,3 +90,29 @@
end:
ret void
}
+
+%mystruct = type { [12 x i8] }
+
+define i32 @struct_type_test(%mystruct* %v0, %mystruct* %v1) {
+;CHECK-LABEL: @struct_type_test
+entry:
+;CHECK-NOT: %const = bitcast i96 32 to i96
+ %v2 = bitcast %mystruct* %v1 to i96*
+ %load0 = load i96, i96* %v2, align 4
+ %v3 = bitcast %mystruct* %v0 to i96*
+ %load1 = load i96, i96* %v3, align 4
+;CHECK: lshr0 = lshr i96 %load0, 32
+ %lshr0 = lshr i96 %load0, 32
+ %cast0 = trunc i96 %lshr0 to i32
+;lshr1 = lshr i96 %load1, 32
+ %lshr1 = lshr i96 %load1, 32
+ %cast1 = trunc i96 %lshr1 to i32
+ %cmp = icmp eq i32 %cast0, %cast1
+ br i1 %cmp, label %if.then, label %if.else
+
+if.then:
+ ret i32 1
+
+if.else:
+ ret i32 2;
+}
Index: lib/Target/ARM/ARMTargetTransformInfo.cpp
===================================================================
--- lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -19,7 +19,7 @@
assert(Ty->isIntegerTy());
unsigned Bits = Ty->getPrimitiveSizeInBits();
- if (Bits == 0 || Bits > 64)
+ if (Bits == 0 || Imm.getActiveBits() >= 64)
return 4;
int64_t SImmVal = Imm.getSExtValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21668.61811.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160624/d1b7ff26/attachment.bin>
More information about the llvm-commits
mailing list