[PATCH] D44909: [DAGCombine] (float)((int) f) --> ftrunc (PR36617)

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 26 18:26:25 PDT 2018


nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Ah, OK. The language reference clearly states that unrepresentable values produce undefined results. As far as PPC is concerned, this LGTM.

P.S. If you think it's appropriate, perhaps it would be nice to add this PPC test case since PPC has `FTRUNC` for vectors as well:

  ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
  ; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-unknown \
  ; RUN:   -verify-machineinstrs < %s | FileCheck %s
  
  define <4 x float> @truncf32(<4 x float> %a) {
  ; CHECK-LABEL: truncf32:
  ; CHECK:       # %bb.0: # %entry
  ; CHECK-NEXT:    xvrspiz 34, 34
  ; CHECK-NEXT:    blr
  entry:
    %0 = fptosi <4 x float> %a to <4 x i32>
    %1 = sitofp <4 x i32> %0 to <4 x float>
    ret <4 x float> %1
  }
  
  define <2 x double> @truncf64(<2 x double> %a) {
  ; CHECK-LABEL: truncf64:
  ; CHECK:       # %bb.0: # %entry
  ; CHECK-NEXT:    xvrdpiz 34, 34
  ; CHECK-NEXT:    blr
  entry:
    %0 = fptosi <2 x double> %a to <2 x i64>
    %1 = sitofp <2 x i64> %0 to <2 x double>
    ret <2 x double> %1
  }
  
  define <4 x float> @truncf32u(<4 x float> %a) {
  ; CHECK-LABEL: truncf32u:
  ; CHECK:       # %bb.0: # %entry
  ; CHECK-NEXT:    xvrspiz 34, 34
  ; CHECK-NEXT:    blr
  entry:
    %0 = fptoui <4 x float> %a to <4 x i32>
    %1 = uitofp <4 x i32> %0 to <4 x float>
    ret <4 x float> %1
  }
  
  define <2 x double> @truncf64u(<2 x double> %a) {
  ; CHECK-LABEL: truncf64u:
  ; CHECK:       # %bb.0: # %entry
  ; CHECK-NEXT:    xvrdpiz 34, 34
  ; CHECK-NEXT:    blr
  entry:
    %0 = fptoui <2 x double> %a to <2 x i64>
    %1 = uitofp <2 x i64> %0 to <2 x double>
    ret <2 x double> %1
  }


https://reviews.llvm.org/D44909





More information about the llvm-commits mailing list