Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4259b5

Browse files
topperctstellar
authored andcommitted
[Float2Int] Pre-commit test for SIToFP/UIToFP ConstantRange bug. NFC
The range for these operations is being constructed without the maximum value for the range due to an incorrect usage of the ConstantRange constructor. This causes Float2Int to think the range for 'uitofp i1' only contains 0 instead of 0 and 1. (cherry picked from commit 6295e67)
1 parent daca56d commit e4259b5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt < %s -passes=float2int -S | FileCheck %s
3+
4+
define i32 @pr79158(i32 %x) {
5+
; CHECK-LABEL: define i32 @pr79158(
6+
; CHECK-SAME: i32 [[X:%.*]]) {
7+
; CHECK-NEXT: entry:
8+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], 0
9+
; CHECK-NEXT: [[TMP0:%.*]] = zext i1 [[CMP]] to i32
10+
; CHECK-NEXT: [[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
11+
; CHECK-NEXT: ret i32 [[MUL1]]
12+
;
13+
entry:
14+
%cmp = icmp sgt i32 %x, 0
15+
%conv = uitofp i1 %cmp to double
16+
%mul = fmul double %conv, 0x41EFFFFFFFE00000
17+
%conv1 = fptoui double %mul to i32
18+
ret i32 %conv1
19+
}

0 commit comments

Comments
 (0)