According the discuss on D154953, we need to make the LangRef change
before the optimization relied on the new behaviour:
vscale_range implies vscale is a power-of-two value, parse of the
attribute to reject values that are not a power-of-two.
Thanks nikic for the wonderful summary of discussing on D154953:
To provide a bit more context here. We would like to have power of two vscale exposed in a target-independent way, so we can make use of this in places like ValueTracking, just like we currently do the vscale range. Some options that have been discussed are:
- Remove support for non-power-of-two vscales entirely. (This is my personal preference, but this is hard to undo if it turns out someone does need them.)
- Add an extra attribute vscale_pow2, or a data layout property.
- Make vscale_range imply power-of-two vscale, as a compromise solution (what this patch does). This would be relatively easy to turn into one of the two above at a later point.
Reviewed By: paulwalker-arm, nikic, efriedma
Differential Revision: https://reviews.llvm.org/D155193
44 lines
1.1 KiB
LLVM
44 lines
1.1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
define i8 @vscale_trunc_i32toi8() vscale_range(1, 128) {
|
|
; CHECK-LABEL: @vscale_trunc_i32toi8(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i8 @llvm.vscale.i8()
|
|
; CHECK-NEXT: ret i8 [[TMP0]]
|
|
;
|
|
entry:
|
|
%0 = call i32 @llvm.vscale.i32()
|
|
%1 = trunc i32 %0 to i8
|
|
ret i8 %1
|
|
}
|
|
|
|
|
|
define i8 @vscale_trunc_i32toi8_poison() vscale_range(1, 256) {
|
|
; CHECK-LABEL: @vscale_trunc_i32toi8_poison(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.vscale.i32()
|
|
; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[TMP0]] to i8
|
|
; CHECK-NEXT: ret i8 [[TMP1]]
|
|
;
|
|
entry:
|
|
%0 = call i32 @llvm.vscale.i32()
|
|
%1 = trunc i32 %0 to i8
|
|
ret i8 %1
|
|
}
|
|
|
|
define i8 @vscale_trunc_i32toi8_noAttr() {
|
|
; CHECK-LABEL: @vscale_trunc_i32toi8_noAttr(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.vscale.i32()
|
|
; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[TMP0]] to i8
|
|
; CHECK-NEXT: ret i8 [[TMP1]]
|
|
;
|
|
entry:
|
|
%0 = call i32 @llvm.vscale.i32()
|
|
%1 = trunc i32 %0 to i8
|
|
ret i8 %1
|
|
}
|
|
|
|
declare i32 @llvm.vscale.i32()
|