[llvm-commits] [llvm] r168181 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll
Chandler Carruth
chandlerc at google.com
Fri Nov 16 11:26:49 PST 2012
On Fri, Nov 16, 2012 at 10:55 AM, Duncan Sands <baldrick at free.fr> wrote:
> Author: baldrick
> Date: Fri Nov 16 12:55:49 2012
> New Revision: 168181
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168181&view=rev
> Log:
> Fix PR14361: wrong simplification of A+B==B+A. You may think that the old logic
> replaced by this patch is equivalent to the new logic, but you'd be wrong, and
> that's exactly where the bug was. There's a similar bug in instsimplify which
> manifests itself as instsimplify failing to simplify this, rather than doing it
> wrong, see next commit.
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> llvm/trunk/test/Transforms/InstCombine/icmp.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=168181&r1=168180&r2=168181&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Fri Nov 16 12:55:49 2012
> @@ -2356,8 +2356,20 @@
> // Try not to increase register pressure.
> BO0->hasOneUse() && BO1->hasOneUse()) {
> // Determine Y and Z in the form icmp (X+Y), (X+Z).
> - Value *Y = (A == C || A == D) ? B : A;
> - Value *Z = (C == A || C == B) ? D : C;
Maybe a comment about why this set of tests is the correct way to
determine Y and Z?
> + Value *Y, *Z;
> + if (A == C) {
> + Y = B;
> + Z = D;
> + } else if (A == D) {
> + Y = B;
> + Z = C;
> + } else if (B == C) {
> + Y = A;
> + Z = D;
> + } else if (B == D) {
> + Y = A;
> + Z = C;
> + }
Maybe add an:
} else {
llvm_unreachable(...);
}
so that we catch a bug of this form with something cheaper than Valgrind.
More information about the llvm-commits
mailing list