[Bug inline-asm/65640] multiple alternative constraints and earlyclobbers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65640 Segher Boessenkool changed: What|Removed |Added CC||segher at gcc dot gnu.org --- Comment #3 from Segher Boessenkool --- (Please don't quote from previous messages when not replying to those lines). This only fails with -O0. IRA assigns the following: int f(int out, int in) { asm("foo %1,%0;" : "=" (out) : "b" (in));// a a asm("foo %1,%0;" : "=" (out) : "b" (in));// a b asm("foo %1,%0;" : "=" (out) : "a" (in));// a b asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // a b asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // a b asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // a b asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // a b return out; } The LRA is left to clean up after it, and it comes up with int f(int out, int in) { asm("foo %1,%0;" : "=" (out) : "b" (in));// a b asm("foo %1,%0;" : "=" (out) : "b" (in));// - - asm("foo %1,%0;" : "=" (out) : "a" (in));// - - asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // a b asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // - - asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // a b asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // b a return out; } (The "- -" are when LRA couldn't come up with something that works).
[Bug inline-asm/65640] multiple alternative constraints and earlyclobbers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65640 --- Comment #2 from Eric Gallager --- (In reply to Eric Gallager from comment #1) > (In reply to Mike Herrick from comment #0) > > There seems to be an issue with earlyclobbers and multiple alternative > > constraints. Take this example: > > > > int f(int out, int in) { > > asm("foo %1,%0;" : "=" (out) : "b" (in));// Okay > > asm("foo %1,%0;" : "=" (out) : "b" (in));// Expected error > > asm("foo %1,%0;" : "=" (out) : "a" (in));// Expected error > > asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // Okay > > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Unexpected error > > asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // Okay > > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Okay > > return out; > > } > > > > With 4.9.2, I see three errors: > > > > $ g++492 -S ex.c > > ex.c: In function 'int f(int, int)': > > ex.c:3:47: error: 'asm' operand has impossible constraints > > asm("foo %1,%0;" : "=" (out) : "b" (in));// Expected error > >^ > > ex.c:4:47: error: 'asm' operand has impossible constraints > > asm("foo %1,%0;" : "=" (out) : "a" (in));// Expected error > >^ > > ex.c:6:52: error: 'asm' operand has impossible constraints > > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Unexpected error > > ^ > > > > The first two are expected, but I'm at a loss to explain the third error. > > In all four of the multi alternative constrain cases, there is exactly one > > "good" constraint and one "bad" constraint in the pair, yet only one of the > > four cases is diagnosed. > > > > What is the expected behavior for this case? > > Confirmed that I get errors in the same places as you; I'm not sure exactly > what the expected behavior is though. Maybe someone else can answer. Any ideas on who else could answer? There's no "inline-asm" maintainer listed in the MAINTAINERS file...
[Bug inline-asm/65640] multiple alternative constraints and earlyclobbers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65640 Eric Gallager changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-07-28 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Gallager --- (In reply to Mike Herrick from comment #0) > There seems to be an issue with earlyclobbers and multiple alternative > constraints. Take this example: > > int f(int out, int in) { > asm("foo %1,%0;" : "=" (out) : "b" (in));// Okay > asm("foo %1,%0;" : "=" (out) : "b" (in));// Expected error > asm("foo %1,%0;" : "=" (out) : "a" (in));// Expected error > asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // Okay > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Unexpected error > asm("foo %1,%0;" : "=," (out) : "b,b" (in)); // Okay > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Okay > return out; > } > > With 4.9.2, I see three errors: > > $ g++492 -S ex.c > ex.c: In function 'int f(int, int)': > ex.c:3:47: error: 'asm' operand has impossible constraints > asm("foo %1,%0;" : "=" (out) : "b" (in));// Expected error >^ > ex.c:4:47: error: 'asm' operand has impossible constraints > asm("foo %1,%0;" : "=" (out) : "a" (in));// Expected error >^ > ex.c:6:52: error: 'asm' operand has impossible constraints > asm("foo %1,%0;" : "=," (out) : "a,a" (in)); // Unexpected error > ^ > > The first two are expected, but I'm at a loss to explain the third error. > In all four of the multi alternative constrain cases, there is exactly one > "good" constraint and one "bad" constraint in the pair, yet only one of the > four cases is diagnosed. > > What is the expected behavior for this case? Confirmed that I get errors in the same places as you; I'm not sure exactly what the expected behavior is though. Maybe someone else can answer.