HomePhabricator

[IRCE] Fix buggy behavior in Clamp

Authored by mkazantsev on Aug 18 2017, 3:50 PM.

Description

[IRCE] Fix buggy behavior in Clamp

Clamp function was too optimistic when choosing signed or unsigned min/max function for calculations.
In fact, !IsSignedPredicate guarantees us that Smallest and Greatest can be compared safely using unsigned
predicates, but we did not check this for S which can in theory be negative.

This patch makes Clamp use signed min/max for cases when it fails to prove S being non-negative,
and it adds a test where such situation may lead to incorrect conditions calculation.

Differential Revision: https://reviews.llvm.org/D36873

llvm-svn: 311205

Details

Committed
mkazantsevAug 18 2017, 3:50 PM
Differential Revision
D36873: [IRCE] Fix buggy behavior in Clamp
Parents
rGb29bebe47b33: IR: Make stripDebugInfo robust against (invalid) empty basic blocks
Branches
Unknown
Tags
Unknown