Skip to content

Commit

Permalink
[Float2Int] Pre-commit test for SIToFP/UIToFP ConstantRange bug. NFC
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
topperc authored and llvmbot committed Mar 21, 2024
1 parent 26a1d66 commit d1de758
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions llvm/test/Transforms/Float2Int/pr79158.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes=float2int -S | FileCheck %s

define i32 @pr79158(i32 %x) {
; CHECK-LABEL: define i32 @pr79158(
; CHECK-SAME: i32 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], 0
; CHECK-NEXT: [[TMP0:%.*]] = zext i1 [[CMP]] to i32
; CHECK-NEXT: [[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
; CHECK-NEXT: ret i32 [[MUL1]]
;
entry:
%cmp = icmp sgt i32 %x, 0
%conv = uitofp i1 %cmp to double
%mul = fmul double %conv, 0x41EFFFFFFFE00000
%conv1 = fptoui double %mul to i32
ret i32 %conv1
}

0 comments on commit d1de758

Please sign in to comment.