[PATCH] D21668: [ARM] Fix cost computation for constant hoisting
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 17:12:46 PDT 2016
weimingz created this revision.
weimingz added a subscriber: llvm-commits.
weimingz set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.
Bug: https://llvm.org/bugs/show_bug.cgi?id=28282
When data types like struct is casted to types like i96*, current cost estimator will return 4 although the actual Imm s very small
Repository:
rL LLVM
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.61747.patch
Type: text/x-patch
Size: 1398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160624/909f3759/attachment.bin>
More information about the llvm-commits
mailing list