[llvm-branch-commits] [llvm] e4259b5 - [Float2Int] Pre-commit test for SIToFP/UIToFP ConstantRange bug. NFC

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 10 14:57:42 PDT 2024


Author: Craig Topper
Date: 2024-04-10T14:55:38-07:00
New Revision: e4259b583c92244e2c49c664fad0fbc1bdaa800b

URL: https://github.com/llvm/llvm-project/commit/e4259b583c92244e2c49c664fad0fbc1bdaa800b
DIFF: https://github.com/llvm/llvm-project/commit/e4259b583c92244e2c49c664fad0fbc1bdaa800b.diff

LOG: [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 6295e677220bb6ec1fa8abe2f4a94b513b91b786)

Added: 
    llvm/test/Transforms/Float2Int/pr79158.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Float2Int/pr79158.ll b/llvm/test/Transforms/Float2Int/pr79158.ll
new file mode 100644
index 00000000000000..d041e01a4b5997
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -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
+}


        


More information about the llvm-branch-commits mailing list