[llvm-dev] how to simplify FP ops with an undef operand?

Kaylor, Andrew via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 28 10:43:41 PST 2018


I’m not sure the transformation happening with fdiv is correct. If we have “%y = fdiv float %x, undef” and %x is a NaN then the result will be NaN for any value of the undef, right? So if I understand the undef rules correctly (never a certainty) then we can’t safely replace the expression with undef. We could, I think, replace it with “%y = %x” though. I think the same is true for fadd, fsub, fmul, and frem.

-Andy

From: Sanjay Patel [mailto:spatel at rotateright.com]
Sent: Tuesday, February 27, 2018 6:29 PM
To: llvm-dev <llvm-dev at lists.llvm.org>
Cc: Nuno Lopes <nunoplopes at sapo.pt>; Stephen Canon <scanon at apple.com>; David Majnemer <david.majnemer at gmail.com>; John Regehr <regehr at cs.utah.edu>; Kaylor, Andrew <andrew.kaylor at intel.com>; Sanjoy Das <sanjoy at playingwithpointers.com>; Friedman, Eli <efriedma at codeaurora.org>; Matt Arsenault <arsenm2 at gmail.com>
Subject: how to simplify FP ops with an undef operand?

%y = fadd float %x, undef

Can we simplify this?

Currently in IR, we do nothing for fadd/fsub/fmul. For fdiv/frem, we propagate undef. The code comment for fdiv/frem says:
"the undef could be a snan"

If that's correct, then shouldn't it be the same for fadd/fsub/fmul? But this can't be correct because we support targets that don't raise exceptions...and even targets that raise exceptions do not trap by default on snan?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180228/0c5a43b1/attachment-0001.html>


More information about the llvm-dev mailing list