]> granicus.if.org Git - llvm/commit
[SystemZ] Do not return INT_MIN from strcmp/memcmp
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 6 Feb 2019 15:10:13 +0000 (15:10 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 6 Feb 2019 15:10:13 +0000 (15:10 +0000)
commit44f220f910f32a658f1afb93ca5f1a2caa63c57c
tree59c3afbc8b660e8be8567e21c7937b6183c2b713
parentfad01c3782cd0ff9cac72a7bbf6a63cb288c8253
[SystemZ] Do not return INT_MIN from strcmp/memcmp

The IPM sequence currently generated to compute the strcmp/memcmp
result will return INT_MIN for the "less than zero" case.  While
this is in compliance with the standard, strictly speaking, it
turns out that common applications cannot handle this, e.g. because
they negate a comparison result in order to implement reverse
compares.

This patch changes code to use a different sequence that will result
in -2 for the "less than zero" case (same as GCC).  However, this
requires that the two source operands of the compare instructions
are inverted, which breaks the optimization in removeIPMBasedCompare.
Therefore, I've removed this (and all of optimizeCompareInstr), and
replaced it with a mostly equivalent optimization in combineCCMask
at the DAGcombine level.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353304 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZInstrInfo.cpp
lib/Target/SystemZ/SystemZInstrInfo.h
lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp
test/CodeGen/SystemZ/memcmp-01.ll
test/CodeGen/SystemZ/strcmp-01.ll